Add failed PR comment job (#3808) Bruception

* Add failed PR comment job

* test

* .

* test

* Download workflow artifact

* .

* test

* .

* test

* nice

* Fix typo
This commit is contained in:
Bruce Berrios 2022-12-07 17:02:13 -05:00 committed by GitHub
parent cb8237a0c0
commit 89fa7dc25d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 38 deletions

View file

@ -1,38 +0,0 @@
name: Comment on failed PR
permissions:
pull-requests: write
on:
workflow_run:
workflows: [PR Check]
types: [completed]
jobs:
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.11.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Read the pr_num file
id: pr_num_reader
uses: juliangruber/read-file-action@v1.0.0
with:
path: ./pr_num/pr_num.txt
- name: Create comment
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: ${{ steps.pr_num_reader.outputs.content }},
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The PR check action failed. Please review the logs and make the necessary changes. ' + context.payload.workflow_run.html_url
})

View file

@ -146,3 +146,21 @@ jobs:
- name: Validate other JSON
if: steps.filter.outputs.other-json == 'true'
run: npm run pr-check-other-json
on-failure:
name: on-failure
runs-on: ubuntu-latest
needs: [ci-be, ci-fe, ci-assets]
if: ${{ always() && contains(needs.*.result, 'failure') && github.ref != 'refs/heads/master' }}
steps:
- name: Comment on PR
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: ${{ github.event.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Continuous integration check(s) failed. Please review the failing check\'s logs and make the necessary changes. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})