Skip to content

Issue Triage

Issue Triage #7

Workflow file for this run

name: Issue Triage
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Triage issue
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const body = issue.body || "";
// Check if the issue contains the template headers
const hasTemplate =
body.includes("Page URL") &&
body.includes("What's wrong") &&
body.includes("Suggested fix") &&
body.includes("Additional context");
if (!hasTemplate) {
// Issue doesn't use template at all - let it through with reminder
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `Thanks for opening this issue.
We've received your request and someone from the Pieces team will take a look. It may take up to **2 business days** to receive a response.
In the meantime, please make sure the following sections are filled out to help us investigate efficiently:
- Page URL
- What's wrong
- Suggested fix (if applicable)
- Additional context
If you think of more details, feel free to edit the issue or add a comment. 🙏`
});
return;
}
// Function to remove HTML comments
const removeComments = (text) => {
return text.replace(/<!--[\s\S]*?-->/g, '');
};
// Extract content after "What's wrong?" header
const whatsWrongMatch = body.match(/What's wrong\?\s*\n+([\s\S]*?)(?=\n#{1,3}\s|$)/i);
const whatsWrongContent = whatsWrongMatch ? removeComments(whatsWrongMatch[1]).trim() : '';
// Check if "What's wrong?" section is empty or only whitespace after removing comments
const whatsWrongIsEmpty = !whatsWrongContent || whatsWrongContent.replace(/\s+/g, '').length === 0;
if (whatsWrongIsEmpty) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `This issue is missing the most critical information: **what's wrong**.
Please describe the problem you're experiencing so we can help you effectively.
This issue will be closed, but feel free to reopen it once you've added:
- A clear description of the problem
- What you expected to happen
- What actually happened
Thank you! 🙏`
});
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ["invalid", "needs-info"]
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: "closed"
});
return;
}
// Issue has content in "What's wrong?" - post welcome message
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `Thanks for opening this issue.
We've received your request and someone from the Pieces team will take a look. It may take up to **2 business days** to receive a response.
In the meantime, please make sure the following sections are filled out to help us investigate efficiently:
- Page URL
- What's wrong
- Suggested fix (if applicable)
- Additional context
If you think of more details, feel free to edit the issue or add a comment. 🙏`
});