Skip to content

Commit 9013135

Browse files
emmyoopmikealfare
andauthored
fail when label is removed (#1097)
Co-authored-by: Mike Alfare <[email protected]>
1 parent 1592ce1 commit 9013135

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/pull-request-checks.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: "If the event is to synchronize, we should remove the label from the PR"
28-
if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'synchronize' && github.event.pull_request.head.repo.full_name != github.repository && contains(github.event.pull_request.labels.*.name, env.CI_LABEL) }}
28+
# also triggers on reopen to avoid a user closing, pushing changes and then reopening the PR
29+
if: ${{ github.event_name == 'pull_request_target' && (github.event.action == 'synchronize' || github.event.action == 'reopened') && github.event.pull_request.head.repo.full_name != github.repository && contains(github.event.pull_request.labels.*.name, env.CI_LABEL) }}
2930
run: |
3031
echo "Synchronizing PR, removing '${{ env.CI_LABEL }}' label"
3132
gh pr edit ${{ github.event.pull_request.number }} --remove-label ${{ env.CI_LABEL }} --repo ${{ github.repository }}
33+
msg="All pull request updates require re-approval of CI. No CI will be run."
34+
echo "::error::$msg"
35+
exit 1
3236
env:
3337
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3438

@@ -52,7 +56,7 @@ jobs:
5256
steps:
5357
- uses: actions/checkout@v4
5458
with:
55-
ref: ${{ github.event.pull_request.head.ref }}
59+
ref: ${{ github.event.pull_request.head.sha }}
5660
repository: ${{ github.event.pull_request.head.repo.full_name }}
5761
- id: changelog-entry-check
5862
uses: dorny/paths-filter@v3
@@ -97,7 +101,7 @@ jobs:
97101
uses: ./.github/workflows/_code-quality.yml
98102
needs: check-run-approval
99103
with:
100-
branch: ${{ github.event.pull_request.head.ref }}
104+
branch: ${{ github.event.pull_request.head.sha }}
101105
repository: ${{ github.event.pull_request.head.repo.full_name }}
102106

103107
verify-build:
@@ -111,7 +115,7 @@ jobs:
111115
package: ${{ fromJSON(needs.affected-packages.outputs.verify-build) }}
112116
with:
113117
package: ${{ matrix.package }}
114-
branch: ${{ github.event.pull_request.head.ref }}
118+
branch: ${{ github.event.pull_request.head.sha }}
115119
repository: ${{ github.event.pull_request.head.repo.full_name }}
116120
os: ${{ vars.DEFAULT_RUNNER }}
117121
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
@@ -128,7 +132,7 @@ jobs:
128132
package: ${{ fromJSON(needs.affected-packages.outputs.unit-tests) }}
129133
with:
130134
package: ${{ matrix.package }}
131-
branch: ${{ github.event.pull_request.head.ref }}
135+
branch: ${{ github.event.pull_request.head.sha }}
132136
repository: ${{ github.event.pull_request.head.repo.full_name }}
133137
os: ${{ vars.DEFAULT_RUNNER }}
134138
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
@@ -143,7 +147,7 @@ jobs:
143147
if: ${{ toJSON(fromJSON(needs.affected-packages.outputs.integration-tests)) != '[]' }}
144148
with:
145149
packages: ${{ needs.affected-packages.outputs.integration-tests }}
146-
branch: ${{ github.event.pull_request.head.ref }}
150+
branch: ${{ github.event.pull_request.head.sha }}
147151
repository: ${{ github.event.pull_request.head.repo.full_name }}
148152
os: ${{ vars.DEFAULT_RUNNER }}
149153
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}

0 commit comments

Comments
 (0)