Skip to content

Commit

Permalink
Fix Cloning in CI for Forks (#249)
Browse files Browse the repository at this point in the history
Fix that manually retrieving the code in the gcc-6 action stage does not work for PRs from forks.
  • Loading branch information
dey4ss authored Sep 12, 2024
1 parent 48a1b82 commit 9a67d24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ jobs:
if: matrix.name == 'gcc-6'
# Recent versions of Github's checkout action do not run on older Ubuntu versions because they use a too recent
# Node.js version. Thus, we have to checkout the code manually.
# Doing so is a bit tricky when it comes to PRs from forks (see #249 for details). The general idea here is that
# we access Github's context information for the event triggering the action's execution and use some details on
# the PR's HEAD if given. Otherwise (for executions due to master updates), we still use the provided
# environment variables.
run: |
apt-get update
apt-get install -y git
git config --global --add safe.directory '*'
git clone "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" .
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 } }') .
git checkout $GITHUB_HEAD_REF
- name: Setup (macOS)
Expand Down

0 comments on commit 9a67d24

Please sign in to comment.