Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit a570d42

Browse files
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

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.github/workflows/issues-and-prs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99
on:
1010
issues:
1111
types: [opened]
12-
pull_request:
12+
pull_request_target:
1313
types: [opened]
1414

1515
jobs:

0 commit comments

Comments
 (0)