Skip to content

Workflow file for this run

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: ['❌ 忽略']
});
}