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

Support public repo PR workflow #56

Merged
merged 21 commits into from
Feb 20, 2021
Merged

Support public repo PR workflow #56

merged 21 commits into from
Feb 20, 2021

Conversation

dorny
Copy link
Owner

@dorny dorny commented Feb 15, 2021

Creating check runs requires access token with write permission.
This is usually not an issue with default ${{ github.token }}.
However this default token lacks write permission when workflow is triggered by PR from forked repo.
It's a security restriction - otherwise it would be possible to get access token to any public repo by simply forking it and creating PR.

There are two workarounds to this problem:

pull_request_target runs in the context of the base of the PR and has write access. It can process event payload in some way. However we need test results from code in target branch and there's no way how to get it.

workflow_run runs in the context of repo default branch and can be triggered when some other workflow is completed.

Therefore our solution is to use two separate workflows:

  1. Workflow is triggered by pull_request event. Tests are executed and results are uploaded as artifacts
  2. workflow_run is triggered afterwards, it downloads artifact with test results and creates test reports

This PR adds support for this workflow.
In this case it's also required to get list of files in target branch using GitHub APIs instead of relying on local clone of repo.

@dorny dorny changed the title WIP: Support public repo PR workflow Support public repo PR workflow Feb 20, 2021
@dorny dorny added the enhancement New feature or request label Feb 20, 2021
@dorny dorny merged commit 603e845 into main Feb 20, 2021
@dorny dorny deleted the artifacts-support branch February 20, 2021 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant