Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check out correct branch on pull_request events #244

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,11 @@ push_to_branch() {
git config --global user.email "${INPUT_GITHUB_USER_EMAIL}"
git config --global user.name "${INPUT_GITHUB_USER_NAME}"

if [ "$INPUT_SKIP_REF_CHECKOUT" != true ] && [ ${GITHUB_REF#refs/heads/} != $GITHUB_REF ]; then
Copy link
Contributor Author

@georeith georeith Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this check: [ ${GITHUB_REF#refs/heads/} != $GITHUB_REF ] was trying to prevent a git checkout error that would occur if this ran on an event type (e.g., pull_request) whose GITHUB_REF is not set to refs/heads/head.

and should be unnecessary now as this should always be able to resolve to a value that can be checked out

git checkout "${GITHUB_REF#refs/heads/}"
if [ "$INPUT_SKIP_REF_CHECKOUT" != true ]; then
CHECKOUT=${GITHUB_HEAD_REF:-${GITHUB_REF}}
CHECKOUT=${CHECKOUT#refs/heads/}
CHECKOUT=${CHECKOUT#refs/tags/}
git checkout "${CHECKOUT}"
fi

if [ -n "$(git show-ref refs/heads/${BRANCH})" ]; then
Expand Down