-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A daemon that reacts to PR comments and fires the presubmit CI Signed-off-by: Oliver Koenig <okoenig@nvidia.com>
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 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,68 @@ | ||
name: watchdog | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
woof: | ||
runs-on: ubuntu-22.04 | ||
if: > | ||
github.event_name == 'issue_comment' && | ||
github.event.issue.pull_request && | ||
startsWith(github.event.comment.body, '/ci') && | ||
contains('ko3n1g,nouiz,joker-eph,yhtang,terrykong,hemildesai,chaserileyroberts,CliveUnger,DwarKapex,mingxu1067,kocchop,SahilJain314,ashors1,maanug-nv,hmonishN,gspschmid', format('{0},', github.actor)) | ||
steps: | ||
- name: Get PR number | ||
shell: bash | ||
id: get-pr-num | ||
run: | | ||
PR_URL="${{ github.event.issue.pull_request.url }}" | ||
PR_NUM=${PR_URL##*/} | ||
echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT | ||
- name: Get Pull Request Information | ||
uses: actions/github-script@v6 | ||
id: get-pr-branch | ||
with: | ||
result-encoding: string | ||
script: | | ||
const pr = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: ${{ steps.get-pr-num.outputs.pr_number }} | ||
}); | ||
console.log('Pull Request Information:', pr.data); | ||
return pr.data.head.ref; | ||
- name: Trigger `CI` workflow on subset of tests | ||
uses: aurelien-baudet/workflow-dispatch@v2.1.1 | ||
id: trigger | ||
with: | ||
workflow: "CI" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-for-completion: false | ||
ref: ${{ steps.get-pr-branch.outputs.result }} | ||
|
||
- name: Update `GITHUB_STEP_SUMMARY` | ||
shell: bash | ||
run: echo "Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run." >> $GITHUB_STEP_SUMMARY | ||
|
||
- name: Update PR issue comment | ||
shell: bash | ||
run: | | ||
message="${{ github.event.comment.body}} | ||
--- | ||
Watchdog 🤖: presubmit CI was automatically triggered. Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run. | ||
" | ||
message="${message//$'\n'/<br>}" | ||
curl -L \ | ||
-X PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }} \ | ||
-d '{"body":"'"$message"'"}' |