-
Dear Github Community, At the end of each of my workflows, a Slack message (using a Slack action) is sent using My question is: can I somehow not run the Slack action step when a PR is made from a forked repository? For example:
I have also thought about allowing the Slack action step to fail, but there seems to be no such feature. Any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 1 reply
-
Assuming you do actually want it to run: This is the type of thing the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. Do I understand correctly that if I append the
Would I still need the regular |
Beta Was this translation helpful? Give feedback.
-
As far as I understand you should be able to use Depending what your workflow does you may need to also ensure you’ve checked out the proper code to analyze/build etc.
|
Beta Was this translation helpful? Give feedback.
-
If
|
Beta Was this translation helpful? Give feedback.
-
Yup, that seems to be the case from my experience. |
Beta Was this translation helpful? Give feedback.
-
@senui ,
When the PR’s head branch and base branch are in the same repository, the above three properties are same.
OR
|
Beta Was this translation helpful? Give feedback.
-
So I tried to go with the I am inclined to go with @brightran’s solution of just ignoring the Slack messages from PRs of forked repos. But I do have a question @brightran:
Will the above step also run if a previous step failed? I used to have as condition Would I have to make a boolean construction as I had in my opening post to take those cases into account? Something like:
Edit: I can confirm that the above construct does indeed work: the Slack action is ignored for forked PRs and taken into account for PRs from the base repository Thanks everyone! |
Beta Was this translation helpful? Give feedback.
-
@senui,
|
Beta Was this translation helpful? Give feedback.
-
senui:
Users without write access to your repo shouldn’t be able to execute arbitrarily modified workflows. That’s why |
Beta Was this translation helpful? Give feedback.
-
@Simran-B, yes, but wouldn’t a PR on the base repo then trigger for both the |
Beta Was this translation helpful? Give feedback.
-
Good point. Yes, it will trigger both if you do
The undesired combinations are skipped. The other two have access to secrets. If the PR branch is in the same repo, then changes to the workflow contained in the PR will apply immediately (i.e. you as maintainer can test workflow changes). If the PR has its branch in a forked repo, then workflow changes won’t be run (the origin version of the workflow is used). In the skipped combination of |
Beta Was this translation helpful? Give feedback.
@senui ,
When the workflow is triggered by the events that are related to pull request ( pull_request, pull_request_review, pull_request_review_comment or pull_request_target), from the github context of the workflow run, you can get the following three properties:
github.event.pull_request.base.repo.full_name - - The full name of PR’s base (target) repository (owner-name/repo-name).
github.event.pull_request.head.repo.full_name - - The full name of PR’s head (source) repository (owner-name/repo-name).
github.repository - - The full name of the repository where the PR is in. Normally this property is equal to ‘github.event.pull_request.base.repo.full_name’.
When the PR’s head bran…