Skip to content

fix: check out correct branch on pull_request events#244

Merged
andrii-bodnar merged 2 commits intocrowdin:masterfrom
georeith:fix/checkout-on-pull-request-event
Sep 6, 2024
Merged

fix: check out correct branch on pull_request events#244
andrii-bodnar merged 2 commits intocrowdin:masterfrom
georeith:fix/checkout-on-pull-request-event

Conversation

@georeith
Copy link
Copy Markdown
Contributor

@georeith georeith commented Sep 5, 2024

Fixes: #242

Uses GITHUB_HEAD_REF if available (which points to the head on pull_request event triggers) and falls back to ${GITHUB_REF#refs/heads/} or ${GITHUB_REF#refs/tags/} otherwise.

As per the docs, GITHUB_REF has 3 possible values:

  • refs/pull/<pr_number>/merge: pull_request events where GITHUB_HEAD_REF is set to the actual head
  • refs/tags/<tag_name>: release events, this PR extracts the tag_name and checks that out
  • refs/heads/<branch_name>: all other events such as push

image
image

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
Copy Markdown
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

Copy link
Copy Markdown
Member

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

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

LGTM, @georeith thank you for the contribution!

@andrii-bodnar andrii-bodnar merged commit 215ab1c into crowdin:master Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_pull_request doesn't check out branch when called from pull_request event

2 participants