GH Actions: fix PR comment conundrum #43
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As described in issue #42, the PR comment to review the pre-processed wiki files was not being posted on PRs coming from forks, while it is all the more relevant for those, as outside contributors may not be aware of the artifact with the wiki files being available.
I've now done some more research into this and believe the changes in this PR will fix this.
The most important take-away from my research is as follows:
secrets.GITHUB_TOKEN
and no access to Personal Access Tokens.secrets.GITHUB_TOKEN
as they are run in the context of themain
branch, not in the context of the PR branch (which is also why I had to briefly usemain
to test this PR).So, with that in mind, I've moved the "comment on PR" step to a separate workflow which is triggered once the "Publish wiki" workflow has completed and will only run for pull requests.
This new workflow had access to the artifacts created by the triggering workflow, but doesn't have access to much else, while it needs access to the PR number of the PR which triggered the workflow cascade + access to the download URL for the wiki files artifact.
Those pieces of information are both available in the "triggering workflow", so we need to store them in - you guessed it - an artifact, so that info can then be retrieved by the second (PR comment) workflow.
Other notes:
fatal: could not read Username for 'https://github.com': No such device or address
.As the "Deploy to wiki" step needs a Personal Access Token for the push to the wiki, this is no great surprise, what with PRs from forks not having access to the PAT.
Switching to the
secrets.GITHUB_TOKEN
just and only for the dry-run, unfortunately would still fail for PRs from works, so I've now made the "Deploy to wiki" step conditional on the workflow either not being triggered by a PR or the PR not coming from a fork.Related issues/external references
Fixes #42
Refs:
Additional info
I've tested this by briefly adding just the new
pr-comment.yml
workflow to themain
branch and then rebasing this PR on top of the "temporary"main
branch. As can be seen via the below comment, the workflow changes are working (keep in mind, this PR is coming from a fork to allow for testing this change).