Skip to content

Commit bea4637

Browse files
authored
chore: Update ci.yaml (#521)
* Update ci.yaml Include missing configuration to run a job on "tests: run" label * Update ci.yaml add additional step to remove pr label
1 parent 55e39d9 commit bea4637

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/ci.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ permissions: read-all
2929

3030
jobs:
3131
units:
32+
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label)
33+
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}"
3234
name: unit-tests (linux)
3335
runs-on: ubuntu-latest
3436
permissions:
@@ -40,6 +42,22 @@ jobs:
4042
matrix:
4143
java: [8, 11, 17]
4244
steps:
45+
- name: Remove PR label
46+
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
47+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
48+
with:
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
script: |
51+
try {
52+
await github.rest.issues.removeLabel({
53+
name: 'tests: run',
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
issue_number: context.payload.pull_request.number
57+
});
58+
} catch (e) {
59+
console.log('Failed to remove label. Another job may have already removed it!');
60+
}
4361
- name: Checkout code
4462
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4563
with:
@@ -75,13 +93,31 @@ jobs:
7593
./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
7694
7795
windows:
96+
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label)
97+
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}"
7898
name: unit-tests (windows)
7999
runs-on: windows-latest
80100
permissions:
81101
contents: "read"
82102
id-token: "write"
83103
issues: write
84104
steps:
105+
- name: Remove PR label
106+
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
107+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
108+
with:
109+
github-token: ${{ secrets.GITHUB_TOKEN }}
110+
script: |
111+
try {
112+
await github.rest.issues.removeLabel({
113+
name: 'tests: run',
114+
owner: context.repo.owner,
115+
repo: context.repo.repo,
116+
issue_number: context.payload.pull_request.number
117+
});
118+
} catch (e) {
119+
console.log('Failed to remove label. Another job may have already removed it!');
120+
}
85121
- name: Support longpaths
86122
run: git config --system core.longpaths true
87123
- name: Checkout code

0 commit comments

Comments
 (0)