|
| 1 | +name: Add labels based on issue closure reason |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [closed] |
| 6 | + |
| 7 | +jobs: |
| 8 | + add-labels: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Check if the issue was closed as completed and add label |
| 12 | + uses: actions/github-script@v6 |
| 13 | + with: |
| 14 | + github-token: ${{ secrets.BOT }} |
| 15 | + script: | |
| 16 | + if (context.payload.issue.state_reason === 'completed') { |
| 17 | + await github.rest.issues.addLabels({ |
| 18 | + owner: context.repo.owner, |
| 19 | + repo: context.repo.repo, |
| 20 | + issue_number: context.payload.issue.number, |
| 21 | + labels: ['👌 完成'] |
| 22 | + }); |
| 23 | + } |
| 24 | +
|
| 25 | + - name: Check if the issue was closed as duplicate and add label |
| 26 | + uses: actions/github-script@v6 |
| 27 | + with: |
| 28 | + github-token: ${{ secrets.BOT }} |
| 29 | + script: | |
| 30 | + if (context.payload.issue.state_reason === 'duplicate') { |
| 31 | + await github.rest.issues.addLabels({ |
| 32 | + owner: context.repo.owner, |
| 33 | + repo: context.repo.repo, |
| 34 | + issue_number: context.payload.issue.number, |
| 35 | + labels: ['❌ 重复'] |
| 36 | + }); |
| 37 | + } |
| 38 | + |
| 39 | + - name: Check if the issue was closed as not planned and add label |
| 40 | + uses: actions/github-script@v6 |
| 41 | + with: |
| 42 | + github-token: ${{ secrets.BOT }} |
| 43 | + script: | |
| 44 | + if (context.payload.issue.state_reason === 'not_planned') { |
| 45 | + await github.rest.issues.addLabels({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + issue_number: context.payload.issue.number, |
| 49 | + labels: ['❌ 忽略'] |
| 50 | + }); |
| 51 | + } |
| 52 | +
|
0 commit comments