This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Commit a570d42
authored
Fix Slack notification not working for PRs from forks (#1459)
I (and potential outside contributors) don't commit branches to the
`QuesmaOrg/quesma` repo, but to personal forks. For such a workflow, the
`issues-and-prs.yml` job (Slack notifications for new PRs/issues) didn't
work, failing with error:
> Missing input! A token must be provided to use the method decided.
The problem is that the Slack token GitHub secret isn't available for
forks - due to security reasons.
However, by changing the type of job from `pull_request` to
`pull_request_target`, it changes how GitHub will run the job - it will
run it in context of "parent" repo (`QuesmaOrg/quesma`), meaning it has
access to the Slack token.
Some [GitHub
documentation](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target)
for context:
> [With 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. This prevents execution of unsafe code from
the head of the pull request that could alter your repository or steal
any secrets you use in your workflow. **This event allows your workflow
to do things like label or comment on pull requests from forks**. Avoid
using this event if you need to build or run code from the pull request.1 parent b725f88 commit a570d42
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments