|
1 | 1 | name: Close issue/PR on adding invalid label |
2 | 2 |
|
3 | | -# **What it does**: This action closes issues that are labeled as invalid in the repo. |
| 3 | +# **What it does**: This action closes issues and PRs that are labeled as invalid in the repo. |
4 | 4 |
|
5 | 5 | on: |
6 | 6 | issues: |
7 | 7 | types: [labeled] |
8 | | - pull_request_target: |
| 8 | + pull_request: |
9 | 9 | types: [labeled] |
10 | 10 |
|
11 | | -permissions: |
12 | | - contents: read |
13 | | - issues: write |
14 | | - pull-requests: write |
| 11 | +permissions: {} |
15 | 12 |
|
16 | 13 | jobs: |
17 | | - close-on-adding-invalid-label: |
18 | | - if: |
19 | | - github.repository == 'github/copilot-cli' && github.event.label.name == |
20 | | - 'invalid' |
| 14 | + close-issue-on-adding-invalid-label: |
| 15 | + if: > |
| 16 | + github.repository == 'github/copilot-cli' && |
| 17 | + github.event_name == 'issues' && |
| 18 | + github.event.label.name == 'invalid' |
21 | 19 | runs-on: ubuntu-latest |
22 | | - |
| 20 | + permissions: |
| 21 | + issues: write |
23 | 22 | steps: |
24 | 23 | - name: Close issue |
25 | | - if: ${{ github.event_name == 'issues' }} |
26 | 24 | env: |
27 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | | - URL: ${{ github.event.issue.html_url }} |
29 | | - run: gh issue close $URL |
| 25 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + GH_REPOSITORY: ${{ github.repository }} |
| 27 | + ISSUE_NUMBER: ${{ github.event.issue.number }} |
| 28 | + run: gh api -X PATCH "repos/$GH_REPOSITORY/issues/$ISSUE_NUMBER" -f state=closed |
30 | 29 |
|
31 | | - - name: Close PR |
32 | | - if: ${{ github.event_name == 'pull_request_target' }} |
33 | | - env: |
34 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
35 | | - URL: ${{ github.event.pull_request.html_url }} |
36 | | - run: gh pr close $URL |
| 30 | + signal-invalid-pr-label: |
| 31 | + if: > |
| 32 | + github.repository == 'github/copilot-cli' && |
| 33 | + github.event_name == 'pull_request' && |
| 34 | + github.event.label.name == 'invalid' |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + pull-requests: read |
| 38 | + steps: |
| 39 | + - name: Record invalid PR label signal |
| 40 | + run: echo "Invalid label signal for PR #${{ github.event.pull_request.number }}" |
0 commit comments