From a93abf7002bc67d9d9d4ae7c8585cf897bd6044e Mon Sep 17 00:00:00 2001 From: Oliver Koenig Date: Tue, 14 May 2024 10:02:07 +0200 Subject: [PATCH] ci: Add `watchdog` A daemon that reacts to PR comments and fires the presubmit CI Signed-off-by: Oliver Koenig --- .github/workflows/_watchdog.yaml | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/_watchdog.yaml diff --git a/.github/workflows/_watchdog.yaml b/.github/workflows/_watchdog.yaml new file mode 100644 index 000000000..99c1237ef --- /dev/null +++ b/.github/workflows/_watchdog.yaml @@ -0,0 +1,50 @@ +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 + echo "${{ github.event.commment.user.login }}" + + - 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: Fetch latest run of `CI` + shell: bash + run: echo "Click [here](${{ steps.trigger.outputs.workflow-url }}) to navigate to the workflow run." >> $GITHUB_STEP_SUMMARY \ No newline at end of file