-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #4594 : Issue Triaging Action Added #5591
base: develop
Are you sure you want to change the base?
Changes from 9 commits
60d9637
d445fde
c979ab6
25260c6
140dc54
e3536d6
6ffb172
3b50f7b
c4391f8
342e76d
e8418d0
8037973
b7c3a05
3ae348d
4ed9640
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Issue Triage and Management | ||
|
||
on: | ||
issues: | ||
types: [opened, labeled, assigned] | ||
|
||
permissions: | ||
issues: write | ||
|
||
jobs: | ||
triage-on-issue-open: | ||
runs-on: ubuntu-latest | ||
if: github.event.sender.login != 'github-actions' | ||
steps: | ||
- name: Reply to Issue (Only on Opened) | ||
adhiamboperes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if: ${{ github.event.action == 'opened' }} | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Thanks for filing the issue! We’ll review it shortly and route it to the correct team. | ||
|
||
- name: Check Labels for Proper Triaging | ||
id: check-labels | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const issue = await github.rest.issues.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number | ||
}); | ||
const labels = issue.data.labels.map(label => label.name); | ||
const requiredLabels = { | ||
types: ['bug', 'enhancement', 'good first issue'], | ||
impacts: ['Impact: High', 'Impact: Medium', 'Impact: Low'], | ||
work: ['Work: High', 'Work: Medium', 'Work: Low'], | ||
priorities: ['Priority: Essential', 'Priority: Important', 'Priority: Nice-to-have'] | ||
}; | ||
const hasTypeLabel = labels.some(label => requiredLabels.types.includes(label)); | ||
const hasImpactLabel = labels.some(label => requiredLabels.impacts.includes(label)); | ||
const hasWorkLabel = labels.some(label => requiredLabels.work.includes(label)); | ||
const hasPriorityLabel = labels.some(label => requiredLabels.priorities.includes(label)); | ||
const needsTriage = !(hasTypeLabel && hasImpactLabel && hasWorkLabel && hasPriorityLabel); | ||
core.setOutput('needs-triage', needsTriage); | ||
|
||
- name: Manage Needs Triage Label | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const needsTriage = '${{ steps.check-labels.outputs.needs-triage }}' === 'true'; | ||
if (needsTriage) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the issue requirements, two conditions must be met for triaging:
Both (all) conditions need to be satisfied to remove the |
||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
labels: ['needs-triage'] | ||
}); | ||
} else { | ||
try { | ||
await github.rest.issues.removeLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
name: 'needs-triage' | ||
}); | ||
} catch (error) { | ||
if (error.status !== 404) { | ||
throw error; | ||
} | ||
} | ||
} | ||
|
||
- name: Verify Project Assignment | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const projects = await github.rest.issues.listForRepo({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
const assignedProjects = projects.data.filter(project => project.state === 'open'); | ||
if (assignedProjects.length !== 1) { | ||
console.warn(`Issue must be assigned to exactly one open project. Found: ${assignedProjects.length}`); | ||
} else { | ||
console.log(`Valid project assignment: ${assignedProjects[0].name}`); | ||
} | ||
adhiamboperes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
adhiamboperes marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be beneficial to trigger actions for label removal as well. This way, we can ensure that the needs-triage label is added as soon as any required label is missing, which will help us better track and manage such issues.