-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split github action workflows into two separate workflows
In order to allow the creation of comments on PR's that are coming from forks, we would need to use the `:pull_request_target` event over the `:pull_request` event. Since the `:pull_request_target` event comes with more permissions on the target repo, its not recommended to checkout the code coming from an untrusted fork. Therefore the gh action workflow is now splited into two separate workflows. One workflow keeps working on the `:pull_request` event and checksout the code to perform the diff operation in order to receive gem name, version etc. Afterwards the informations are saved as artifacts. The second workflow listens for the `workflow_run` event and gets triggered after the first one finished successfully, then downloads the artifacts and finally creates the comment (the `:workflow_run` event has permission to comment on the PR).
- Loading branch information
1 parent
2cfbbd4
commit 359b519
Showing
2 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Add Comment with Diffend.io Links to PR | ||
on: | ||
workflow_run: | ||
workflows: ['Create Diffend.io Links and Comment Text'] | ||
types: | ||
- completed | ||
permissions: | ||
contents: read | ||
jobs: | ||
comment_diffend_io_links_to_pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Download artifacts | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
workflow_conclusion: success | ||
- name: Add Comment to PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: comment_text/comment_text.txt | ||
pr_number: ${{ github.event.workflow_run.pull_requests[0].number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters