Skip to content

Commit 8bca260

Browse files
CI: only run for pull_request if run from a fork
1 parent e91e403 commit 8bca260

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,21 @@ env:
2424
LOCALE_ID: 'en-US'
2525

2626
jobs:
27-
check-run:
27+
ci-conditions:
28+
name: 'CI conditions'
2829
runs-on: 'ubuntu-latest'
2930
outputs:
30-
should-skip: ${{ steps.check.outputs.should-skip }}
31+
IS_FORK: ${{ github.repository_owner != 'getodk' }}
32+
IS_PR: ${{ github.event_name == 'pull_request' }}
33+
3134
steps:
32-
- name: Check for duplicate push event with PR
33-
id: check
34-
if: github.event_name == 'push'
35-
run: |
36-
# Check if this push is tied to an open PR
37-
PR_NUMBER=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
38-
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" | \
39-
jq -r '.[0].number // "none"')
40-
if [ "$PR_NUMBER" != "none" ]; then
41-
echo "This push (commit ${{ github.sha }}) is part of PR #$PR_NUMBER, skipping to avoid duplication with pull_request event."
42-
echo "should-skip=true" >> $GITHUB_OUTPUT
43-
exit 0
44-
else
45-
echo "No associated PR found, proceeding with CI for this push."
46-
echo "should-skip=false" >> $GITHUB_OUTPUT
47-
fi
35+
- name: Capture CI conditions
36+
id: capture-ci-conditions
37+
run: exit 0
4838

4939
install-and-build:
50-
needs: check-run
51-
if: ${{ needs.check-run.outputs.should-skip != 'true' }}
40+
needs: ci-conditions
41+
if: ${{ needs.ci-conditions.outputs.IS_PR != 'true' || needs.ci-conditions.outputs.IS_FORK == 'true' }}
5242
name: 'Install dependencies and build packages'
5343
runs-on: 'ubuntu-latest'
5444

0 commit comments

Comments
 (0)