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