Skip to content

Commit 3bfb3f9

Browse files
ci: verify fork nightlies in pull requests (#9)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 997cc71 commit 3bfb3f9

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

.github/workflows/fork-nightly.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Fork Nightly
22

33
on:
4+
pull_request:
45
schedule:
56
- cron: "23 */6 * * *"
67
workflow_dispatch:
@@ -10,8 +11,8 @@ permissions:
1011
id-token: none
1112

1213
concurrency:
13-
group: fork-nightly
14-
cancel-in-progress: false
14+
group: fork-nightly-${{ github.event.pull_request.number || 'publish' }}
15+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1516

1617
jobs:
1718
prepare:
@@ -30,7 +31,7 @@ jobs:
3031
- name: Checkout fork patch stack
3132
uses: actions/checkout@v6
3233
with:
33-
ref: main
34+
ref: ${{ github.event.pull_request.head.sha || 'main' }}
3435
fetch-depth: 0
3536
sparse-checkout: |
3637
/*
@@ -51,12 +52,13 @@ jobs:
5152
git fetch origin \
5253
'+refs/heads/nightly-candidate:refs/remotes/origin/nightly-candidate' || true
5354
54-
git switch -C nightly-candidate origin/main
55+
git switch -C nightly-candidate HEAD
5556
git rebase upstream/main
5657
5758
candidate_ref=$(git rev-parse HEAD)
5859
has_changes=true
59-
if git rev-parse --verify refs/remotes/origin/nightly >/dev/null 2>&1 && \
60+
if [[ "$GITHUB_EVENT_NAME" != "pull_request" ]] && \
61+
git rev-parse --verify refs/remotes/origin/nightly >/dev/null 2>&1 && \
6062
git diff --quiet origin/nightly HEAD --; then
6163
has_changes=false
6264
fi
@@ -94,7 +96,9 @@ jobs:
9496
9597
- id: release_meta
9698
name: Resolve nightly version
97-
if: steps.candidate.outputs.has_changes == 'true'
99+
if: >-
100+
github.event_name != 'pull_request' &&
101+
steps.candidate.outputs.has_changes == 'true'
98102
shell: bash
99103
env:
100104
CANDIDATE_REF: ${{ steps.candidate.outputs.ref }}
@@ -108,13 +112,17 @@ jobs:
108112
--github-output
109113
110114
- name: Publish verified candidate
111-
if: steps.candidate.outputs.has_changes == 'true'
115+
if: >-
116+
github.event_name != 'pull_request' &&
117+
steps.candidate.outputs.has_changes == 'true'
112118
run: git push --force-with-lease origin HEAD:refs/heads/nightly-candidate
113119

114120
build_macos:
115121
name: Build macOS arm64
116122
needs: prepare
117-
if: needs.prepare.outputs.has_changes == 'true'
123+
if: >-
124+
github.event_name != 'pull_request' &&
125+
needs.prepare.outputs.has_changes == 'true'
118126
runs-on: macos-15
119127
timeout-minutes: 45
120128
steps:
@@ -248,7 +256,10 @@ jobs:
248256
release:
249257
name: Publish GitHub prerelease
250258
needs: [prepare, build_macos]
251-
if: needs.prepare.outputs.has_changes == 'true' && needs.build_macos.result == 'success'
259+
if: >-
260+
github.event_name != 'pull_request' &&
261+
needs.prepare.outputs.has_changes == 'true' &&
262+
needs.build_macos.result == 'success'
252263
runs-on: ubuntu-24.04
253264
timeout-minutes: 10
254265
steps:
@@ -306,6 +317,7 @@ jobs:
306317
needs: [prepare, build_macos, release]
307318
if: >-
308319
${{
320+
github.event_name != 'pull_request' &&
309321
always() &&
310322
(
311323
needs.prepare.result == 'failure' ||

0 commit comments

Comments
 (0)