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

GHA trigger CI with pull_request_target for secrets access #1132

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

AndreKurait
Copy link
Member

@AndreKurait AndreKurait commented Nov 13, 2024

Description

Update pull request trigger to be "pull_request_target" which allows actions to access secrets needed for CODECOV_TOKEN.

Removed codecov retry since this was due to throttling when ran without tokens, the retry didn't help. Also added verbose: true to aid in any future debugging on codecov action.

See documentation: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflows-in-forked-repositories

Note: This will make changes to GHA workflows slightly more complicated, the GHA on the PR will run with the upstream branch workflow definition when triggered on a PR from a forked repository (a security feature). Instead we can push updates to a branch to verify, or temporarily update pull_request_target -> pull_request in a staged commit which will run the forked actions without secrets.

Testing

See GHA

Verified throttle limits aren't hit

Verified PRs run with secrets:

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@AndreKurait AndreKurait marked this pull request as ready for review November 13, 2024 03:48
@AndreKurait AndreKurait changed the title Ci pull request target GHA trigger CI with pull_request_target for secrets access Nov 13, 2024
Copy link
Collaborator

@gregschohn gregschohn left a comment

Choose a reason for hiding this comment

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

Can you please clarify what this means?
"This will make updates to GHA slightly more complicated, they won't run when triggered on a PR from a forked repository (a security feature)."

Does that mean that creating a PR from my fork won't be able to run codecov? Will that show up as an error or would it just not run? Given our current, typical workflow with forked repos, would devs know codecov differences before merging?

.github/workflows/CI.yml Show resolved Hide resolved
@AndreKurait
Copy link
Member Author

Can you please clarify what this means?

"This will make updates to GHA slightly more complicated, they won't run when triggered on a PR from a forked repository (a security feature)."

Does that mean that creating a PR from my fork won't be able to run codecov? Will that show up as an error or would it just not run? Given our current, typical workflow with forked repos, would devs know codecov differences before merging?

The GHA will still run on PRs from a forked repo. They will just use the workflow definition from the upstream branch instead of from the fork.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.74%. Comparing base (d7884e9) to head (75fafba).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1132   +/-   ##
=========================================
  Coverage     80.74%   80.74%           
  Complexity     2924     2924           
=========================================
  Files           399      399           
  Lines         14845    14845           
  Branches       1007     1007           
=========================================
  Hits          11986    11986           
  Misses         2252     2252           
  Partials        607      607           
Flag Coverage Δ
gradle-test 78.75% <ø> (ø)
python-test 89.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AndreKurait AndreKurait merged commit c434c64 into main Nov 13, 2024
17 checks passed
@AndreKurait AndreKurait deleted the ci_pull_request_target branch November 13, 2024 15:30
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