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

Conversation

georeith
Copy link
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

@@ -229,8 +229,8 @@ 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

Copy link
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
6 checks passed
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