Skip to content

Commit 9a67d24

Browse files
authored
Fix Cloning in CI for Forks (#249)
Fix that manually retrieving the code in the gcc-6 action stage does not work for PRs from forks.
1 parent 48a1b82 commit 9a67d24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ jobs:
5555
if: matrix.name == 'gcc-6'
5656
# Recent versions of Github's checkout action do not run on older Ubuntu versions because they use a too recent
5757
# Node.js version. Thus, we have to checkout the code manually.
58+
# Doing so is a bit tricky when it comes to PRs from forks (see #249 for details). The general idea here is that
59+
# we access Github's context information for the event triggering the action's execution and use some details on
60+
# the PR's HEAD if given. Otherwise (for executions due to master updates), we still use the provided
61+
# environment variables.
5862
run: |
5963
apt-get update
6064
apt-get install -y git
6165
git config --global --add safe.directory '*'
62-
git clone "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" .
66+
git clone $(awk -v a=${{github.event.pull_request.head.repo.clone_url}} -v b="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" 'BEGIN { if (a == "") { print b } else { print a } }') .
6367
git checkout $GITHUB_HEAD_REF
6468
6569
- name: Setup (macOS)

0 commit comments

Comments
 (0)