Sitelet https://github.com/dorny/test-reporter/pull/56
Skip to content

Support public repo PR workflow - #56

Merged
dorny merged 21 commits into
mainfrom
artifacts-support
Feb 20, 2021
Merged

dorny merged 21 commits into
mainfrom
artifacts-support

Conversation

@dorny

@dorny dorny commented Feb 15, 2021 •

Copy link
Copy Markdown
Owner

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.

1 participant