|
| 1 | +name: Remove Skip-CI Labels |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [synchronize] |
| 6 | + |
| 7 | +permissions: |
| 8 | + pull-requests: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + remove-skip-ci-labels: |
| 12 | + name: Remove skip-ci labels on new commits |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Get PR labels |
| 16 | + id: get-labels |
| 17 | + uses: actions/github-script@v7 |
| 18 | + with: |
| 19 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + script: | |
| 21 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ |
| 22 | + owner: context.repo.owner, |
| 23 | + repo: context.repo.repo, |
| 24 | + issue_number: context.issue.number |
| 25 | + }); |
| 26 | +
|
| 27 | + const skipCiLabels = labels |
| 28 | + .filter(label => label.name.startsWith('skip-ci:')) |
| 29 | + .map(label => label.name); |
| 30 | +
|
| 31 | + console.log('Found skip-ci labels:', skipCiLabels); |
| 32 | + core.setOutput('skip-ci-labels', JSON.stringify(skipCiLabels)); |
| 33 | + core.setOutput('has-skip-ci-labels', skipCiLabels.length > 0 ? 'true' : 'false'); |
| 34 | +
|
| 35 | + - name: Remove skip-ci labels |
| 36 | + if: steps.get-labels.outputs.has-skip-ci-labels == 'true' |
| 37 | + uses: actions/github-script@v7 |
| 38 | + with: |
| 39 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + script: | |
| 41 | + const skipCiLabels = JSON.parse('${{ steps.get-labels.outputs.skip-ci-labels }}'); |
| 42 | +
|
| 43 | + for (const label of skipCiLabels) { |
| 44 | + console.log(`Removing label: ${label}`); |
| 45 | + await github.rest.issues.removeLabel({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + issue_number: context.issue.number, |
| 49 | + name: label |
| 50 | + }); |
| 51 | + } |
| 52 | +
|
| 53 | + console.log(`Successfully removed ${skipCiLabels.length} skip-ci label(s)`); |
0 commit comments