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

Change some workflows using pull_request to use pull_request_target instead #112161

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

carlossanlop
Copy link
Member

From https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/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.

There are other workflows that are also using pull_request, but we discussed them offline and they're ok using it: jit_format.yml, markdownlint.yml, and all under src/native/external.

I also reduced the scope of the two existing workflows that check labeling.

@carlossanlop carlossanlop requested a review from a team February 4, 2025 23:04
@carlossanlop carlossanlop self-assigned this Feb 4, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@ericstj
Copy link
Member

ericstj commented Feb 4, 2025

@carlossanlop
Copy link
Member Author

anything else in here that needs to change? https://github.com/search?q=repo%3Adotnet%2Fruntime%20pull_request%20path%3A*.yml&type=code

Nope. @jeffhandley listed all in the chat and indicated which ones needed to be updated and which ones were ok.

@carlossanlop carlossanlop merged commit 4c1ae74 into dotnet:main Feb 5, 2025
16 checks passed
@carlossanlop carlossanlop deleted the FixWorkflows branch February 5, 2025 00:05
@carlossanlop
Copy link
Member Author

/backport to release/9.0-staging

@carlossanlop
Copy link
Member Author

/backport to release/8.0-staging

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/13147243831

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/13147246296

Copy link
Contributor

github-actions bot commented Feb 5, 2025

@carlossanlop backporting to "release/8.0-staging" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Change workflows to use pull_request_target instead of pull_request event
Applying: Add CODEOWNERS entry
Using index info to reconstruct a base tree...
M	.github/CODEOWNERS
Falling back to patching base and 3-way merge...
Auto-merging .github/CODEOWNERS
CONFLICT (content): Merge conflict in .github/CODEOWNERS
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Add CODEOWNERS entry
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

Sharing some post-merge feedback. But this really only applies to main and I don't think needs to be backported.

I also realized our workflows aren't all using an if condition to ensure they're being run from dotnet/runtime, and therefore the workflows will run on folks' forks too. aspnetcore-sync.yml checks for dotnet/runtime while locker.yml checks just for the repo owner of dotnet. Either of those approaches works. We should check each workflow to confirm we want them to run on forks. And we should include that guidance in the README as well.

General guidance:

- Please make sure to include the @dotnet/runtime-infrastructure group as a reviewer of your PRs.
- Do not use the `pull_request` event. Use `pull_request_target` instead, as documented in [Workflows in forked repositories](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflows-in-forked-repositories) and [pull_request_target](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target).
Copy link
Member

Choose a reason for hiding this comment

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

I recommend elaborating further to describe the nuance, as it isn't an absolute statement that pull_request_target should always be used. Here's what I suggest:

For workflows that are triggered by pull requests, refer to GitHub's documentation for the pull_request and pull_request_target events. The pull_request_target event is the more common use case in this repository as it runs the workflow in the context of the target branch instead of in the context of the pull request's fork or branch. However, workflows that need to consume the contents of the pull request need to use the pull_request event. There are security considerations with each of the events though.

Refer to GitHub's Workflows in forked repositories and pull_request_target documentation for more information.

@@ -112,3 +112,4 @@
/docs/area-owners.* @jeffhandley
/docs/issue*.md @jeffhandley
/.github/policies/ @jeffhandley @mkArtakMSFT
/.github/workflows/ @dotnet/runtime-infrastructure
Copy link
Member

Choose a reason for hiding this comment

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

Works for me not being explicitly named in the codeowners here, but I'm happy to consult on these at any time so don't hesitate to hit me up for reviews.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about adding you explicitly but you're part of the runtime-infrastructure group. I think you're more experienced than everyone else so it makes sense to have you mentioned like in the line above.

grendello added a commit to grendello/runtime that referenced this pull request Feb 5, 2025
* main:
  JIT: Set PGO data inconsistent when flow disappears in cast expansion (dotnet#112147)
  [H/3] Fix handling H3_NO_ERROR (dotnet#112125)
  Change some workflows using `pull_request` to use `pull_request_target` instead (dotnet#112161)
  Annotate ConfiguredCancelableAsyncEnumerable T with allows ref struct and update extensions (dotnet#111953)
  Delete copy of performance pipelines in previous location (dotnet#112113)
  Optimize BigInteger.Divide (dotnet#96895)
  Use current STJ in HostModel and remove unnecessary audit suppressions (dotnet#109852)
  JIT: Unify handling of InstParam argument during inlining (dotnet#112119)
  Remove unneeded DiagnosticSource content (dotnet#112116)
  Improve compare-and-branch sequences produced by Emitter (dotnet#111797)
  Jit: Conditional Escape Analysis and Cloning (dotnet#111473)
  Re-enable HKDF-SHA3 on Azure Linux
  Remove fstream usage from corehost (dotnet#111859)
carlossanlop added a commit to carlossanlop/runtime that referenced this pull request Feb 6, 2025
…t` instead (dotnet#112161)

* Change workflows to use pull_request_target instead of pull_request event
* Add CODEOWNERS entry
* Add initial readme
carlossanlop added a commit to carlossanlop/runtime that referenced this pull request Feb 6, 2025
…t` instead (dotnet#112161)

* Change workflows to use pull_request_target instead of pull_request event
* Add CODEOWNERS entry
* Add initial readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants