Skip to content

Commit

Permalink
Merge pull request #6 from buildkite-plugins/fix/build-head-commits
Browse files Browse the repository at this point in the history
Ensure when HEAD is used as the commit that the appropriate branch is selected
  • Loading branch information
CerealBoy authored Nov 4, 2024
2 parents 130277c + 764ac92 commit 2511e50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ steps:
- label: ":pipeline:"
command: "buildkite-agent pipeline upload"
plugins:
- git-ssh-checkout#v0.4.0:
- git-ssh-checkout#v0.4.1:
ssh-secret-key-name: 'SUPER_SECRET_SSH_KEY'
```
Expand All @@ -49,7 +49,7 @@ steps:
- label: ":hammer_and_pick: Run linter"
command: "make lint"
plugins: &base-plugins
- git-ssh-checkout#v0.4.0: &checkout-plugin
- git-ssh-checkout#v0.4.1: &checkout-plugin
ssh-secret-key-name: 'SUPER_SECRET_SSH_KEY'
- label: ":hammer_and_pick: Run tests"
Expand All @@ -59,7 +59,7 @@ steps:
- label: ":docker: Build image"
command: "make build-image"
plugins:
- git-ssh-checkout#v0.4.0: *checkout-plugin
- git-ssh-checkout#v0.4.1: *checkout-plugin
- ecr#v2.9.0:
login: true
```
Expand Down
6 changes: 4 additions & 2 deletions hooks/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ if [ "${DRY_RUN}" != "true" ]; then
git fetch -v --prune -- origin "refs/heads/${BUILDKITE_BRANCH}"
fi

# Checkout the SHA
if [ "${BUILDKITE_COMMIT:-}" != "" ]; then
# Checkout the correct ref to continue the build
if [ "${BUILDKITE_COMMIT:-}" = "HEAD" ] || [ "${BUILDKITE_COMMIT}" = "" ]; then
git checkout -f "origin/${BUILDKITE_BRANCH}"
else
git checkout -f "${BUILDKITE_COMMIT}"
fi
fi

0 comments on commit 2511e50

Please sign in to comment.