Skip to content

Commit

Permalink
Updated prettier comment on pr
Browse files Browse the repository at this point in the history
Signed-off-by: George Araújo <[email protected]>
  • Loading branch information
george-gca committed Jan 22, 2024
1 parent fe12d21 commit b2ee83a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
27 changes: 6 additions & 21 deletions .github/workflows/prettier-comment-on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
name: Comment on pull request

on:
workflow_run:
workflows: [Prettier code formatter]
types:
- completed
repository_dispatch:
types: [prettier-failed-on-pr]

jobs:
comment:
# available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
steps:
- name: Download artifacts
id: download-artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: prettier.yml
workflow_conclusion: failure
event: pull_request
- name: Read PR number
id: pr
uses: juliangruber/read-file-action@v1
with:
path: PR/PR.txt
- name: PR comment with html diff
uses: thollander/actions-comment-pull-request@v2
with:
filePath: HTML_Diff/diff.html
pr_number: ${{ steps.pr.outputs.content }}
comment_tag: prettier-failed
pr_number: ${{ github.event.client_payload.pr_number }}
message: |
Failed prettier code verification. Check [this file](${{ github.event.client_payload.artifact_url }}) for more information.
17 changes: 7 additions & 10 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ jobs:
git diff -- . ':(exclude)package-lock.json' ':(exclude)package.json' > diff.txt
npm install -g diff2html-cli
diff2html -i file -s side -F diff.html -- diff.txt
- name: Save PR number
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
run: |
echo ${{ github.event.number }} > PR.txt
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
with:
name: PR
path: PR.txt
retention-days: 1
- name: Upload html diff
id: artifact-upload-step
if: ${{ failure() && steps.prettier.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: HTML_Diff
path: diff.html
retention-days: 3
- name: Dispatch information to repository
if: ${{ failure() && steps.prettier.conclusion == 'failure' && github.event_name == 'pull_request' }}
uses: peter-evans/repository-dispatch@v2
with:
event-type: prettier-failed-on-pr
client-payload: '{"pr_number": "${{ github.event.number }}", "artifact_url": "${{ steps.artifact-upload-step.outputs.artifact-url }}"}'

0 comments on commit b2ee83a

Please sign in to comment.