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

always check out the github.head_ref in CI #1186

Merged
merged 1 commit into from
Feb 24, 2024
Merged

Conversation

RBusarow
Copy link
Collaborator

The default behavior for the actions/checkout is to check out the github.ref commit.

In the case of pull_request_target triggers, the github.ref commit is the last commit on the target branch (typically main), instead of the PR branch:

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target

This event runs in the context of the base of the pull request, rather than in the context of the merge commit, as the pull_request event does.

Unfortunately, that means that unless we specify the correct PR branch, the kotlin.yml workflow jobs will just execute against the main.

@RBusarow RBusarow force-pushed the rick/check-out-head_ref branch from 8ce3a87 to 53d01ee Compare February 23, 2024 20:57
@RBusarow RBusarow marked this pull request as ready for review February 23, 2024 21:18
@RBusarow RBusarow requested review from zach-klippenstein and a team as code owners February 23, 2024 21:18
The default behavior for the `actions/checkout` is to check out the `github.ref` commit.

In the case of `pull_request_target` triggers, the `github.ref` commit is the last commit on the target branch (typically `main`), instead of the PR branch:

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target

> This event runs in the context of the base of the pull request, rather than in the context of the merge commit, as the pull_request event does.

Unfortunately, that means that unless we specify the correct PR branch,
the `kotlin.yml` workflow jobs will just execute against the `main`.
@RBusarow RBusarow force-pushed the rick/check-out-head_ref branch from 53d01ee to b61c214 Compare February 23, 2024 22:34
@RBusarow RBusarow enabled auto-merge February 23, 2024 22:43
Copy link
Contributor

@rjrjr rjrjr left a comment

Choose a reason for hiding this comment

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

I continue to be amazed at how hard it is to do this correctly. Are we really that weird? Our setup seems so clean.

@RBusarow RBusarow merged commit 0c08479 into main Feb 24, 2024
32 checks passed
@RBusarow RBusarow deleted the rick/check-out-head_ref branch February 24, 2024 02:41
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.

2 participants