Skip to content

Commit 3e34774

Browse files
SigureMoCopilot
andauthored
[CI] Add CI for auto remove skip-ci label after commit (#76172)
--------- Co-authored-by: copilot-swe-agent[bot] <[email protected]>
1 parent 6ed9282 commit 3e34774

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)