Skip to content

Commit

Permalink
Merge pull request #473 from btlogy/462.ci-http-checkout
Browse files Browse the repository at this point in the history
CI checkout SHA1 digests and work for both local and remote forks
  • Loading branch information
crwood authored Nov 1, 2024
2 parents 8fda279 + 0cce356 commit 00db814
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,28 @@ orbs:
aliases:
# Custom checkout step using https URL instead of the ssh one provided by GitHub OAuth
# This avoids us having to manage keys only to read a public repo - until we have to push?
# But we have to handle remote branches from external fork (CIRCLE_PR_XXX)
# and local branches from the project itself (CIRCLE_PROJECT)
# In addition, the code will differ between bash and powershell
- &CHECKOUT
run:
name: Checkout code
command: |
git clone -b "${CIRCLE_BRANCH}" "https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git" .
USERNAME=${CIRCLE_PR_USERNAME:-${CIRCLE_PROJECT_USERNAME}}
REPONAME=${CIRCLE_PR_REPONAME:-${CIRCLE_PROJECT_REPONAME}}
git clone "https://github.com/${USERNAME}/${REPONAME}.git" .
git checkout -b "${CIRCLE_BRANCH}" "${CIRCLE_SHA1}"
TERM=ansi git log -n 1 --pretty=oneline
- &CHECKOUT_WINDOWS
run:
name: Checkout code
command: |
git clone -b "$Env:CIRCLE_BRANCH" "https://github.com/$Env:CIRCLE_PROJECT_USERNAME/$Env:CIRCLE_PROJECT_REPONAME.git" .
$USERNAME = if ($Env:CIRCLE_PR_USERNAME -ne $null) { $Env:CIRCLE_PR_USERNAME } else { $Env:CIRCLE_PROJECT_USERNAME }
$REPONAME = if ($Env:CIRCLE_PR_REPONAME -ne $null) { $Env:CIRCLE_PR_REPONAME } else { $Env:CIRCLE_PROJECT_REPONAME }
git clone "https://github.com/$USERNAME/$REPONAME.git" .
git checkout -b "$Env:CIRCLE_BRANCH" "$Env:CIRCLE_SHA1"
git log -n 1 --pretty=oneline
- &PREPARE_VIRTUALENV
run:
Expand Down

0 comments on commit 00db814

Please sign in to comment.