This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Add labels based on issue closure reason | |
on: | |
issues: | |
types: [closed] | |
jobs: | |
add-labels: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if the issue was closed as completed and add label | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.BOT }} | |
script: | | |
if (context.payload.issue.state_reason === 'completed') { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
labels: ['👌 完成'] | |
}); | |
} | |
- name: Check if the issue was closed as duplicate and add label | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.BOT }} | |
script: | | |
if (context.payload.issue.state_reason === 'duplicate') { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
labels: ['❌ 重复'] | |
}); | |
} | |
- name: Check if the issue was closed as not planned and add label | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.BOT }} | |
script: | | |
if (context.payload.issue.state_reason === 'not_planned') { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
labels: ['❌ 忽略'] | |
}); | |
} | |