-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distribute workflows to fork repositories
- Loading branch information
1 parent
e5d972e
commit 6dabe60
Showing
3 changed files
with
75 additions
and
30 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
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,40 @@ | ||
name: Notify test workflow | ||
on: | ||
pull_request_target: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
notify: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: "Notify test workflow" | ||
uses: actions/github-script@v3 | ||
if: ${{ github.base_ref == 'master' }} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const endpoint = "GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch" | ||
const params = { | ||
owner: context.payload.pull_request.head.repo.owner.login, | ||
repo: context.payload.pull_request.head.repo.name, | ||
id: "build_and_test.yml", | ||
branch: context.payload.pull_request.head.ref, | ||
} | ||
const runs = await github.request(endpoint, params) | ||
var runID = runs.data.workflow_runs[0].id | ||
var msg = "**[Test build #" + runID + "]" | ||
+ "(https://github.com/" + context.payload.pull_request.head.repo.full_name | ||
+ "/actions/runs/" + runID + ")** " | ||
+ "for PR " + context.issue.number | ||
+ " at commit [`" + context.payload.pull_request.head.sha.substring(0, 7) + "`]" | ||
+ "(https://github.com/" + context.payload.pull_request.head.repo.full_name | ||
+ "/commit/" + context.payload.pull_request.head.sha + ")." | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.payload.repository.owner.login, | ||
repo: context.payload.repository.name, | ||
body: msg | ||
}) |
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