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

Pull Request Handler - Use Github SHA if possible #1130

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

aholstrup1
Copy link
Collaborator

@aholstrup1 aholstrup1 commented Jul 2, 2024

Problem
With github.event.pull_request.merge_commit_sha we're not guaranteed to get all the latest changes from the head branch included in the build. Often we only get the changes from the second last commit actions/checkout#518 (comment)

Previously we used the merge branch but with the merge branch it's possible to push new changes to a PR from a forked repo and have the PR Build run on unapproved changes.

Proposed Solution
Use Github SHA if possible in the PR Build. Otherwise use the merge branch.

The pull_request trigger will use the github_sha which is the last merge commit on the GITHUB_REF branch. Thereby it should not be possible for the PR Build to run on unapproved changes.

The pull_request_target trigger cannot use the github_sha because it is the last commit on the PR base branch. Instead we'll use the merge branch. With the pull_request_target trigger PR Builds are always triggered right away which means we'll cancel any currently running PR Build once there's a new push to the PR.

@aholstrup1 aholstrup1 marked this pull request as ready for review July 2, 2024 07:23
@aholstrup1 aholstrup1 requested a review from a team as a code owner July 2, 2024 07:23
@aholstrup1 aholstrup1 enabled auto-merge (squash) July 2, 2024 16:05
@aholstrup1 aholstrup1 merged commit 5eeeec5 into microsoft:main Jul 2, 2024
5 checks passed
cegekaJG added a commit to CBS-BC-AT/AL-Go that referenced this pull request Jul 8, 2024
cegekaJG added a commit to CBS-BC-AT/AL-Go that referenced this pull request Jul 8, 2024
freddydk pushed a commit that referenced this pull request Jul 19, 2024
This PR fixes an error introduced by #1130.
The new reference values use the `format()` command to generate a git
reference, but the placeholder syntax was incorrect.
The two instances of `${0}` per template have been replaced with `{0}`.
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.

3 participants