Skip to content

Commit

Permalink
Changed how prettier comments on PR works (alshedivat#2112)
Browse files Browse the repository at this point in the history
Signed-off-by: George Araújo <[email protected]>
  • Loading branch information
george-gca authored Jan 22, 2024
1 parent 7ed8f49 commit 27d2fa0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 42 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/prettier-comment-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Comment on pull request

on:
workflow_run:
workflows: [Prettier code formatter]
types:
- completed

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 artifact
uses: actions/github-script@v7
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "HTML Diff"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/HTML Diff.zip', Buffer.from(download.data));
- name: Unzip artifact
run: unzip HTML\ Diff.zip
- name: PR comment with html diff
# https://docs.github.com/en/actions/learn-github-actions/expressions#failure-with-conditions
uses: thollander/actions-comment-pull-request@v2
with:
filePath: diff.html
40 changes: 0 additions & 40 deletions .github/workflows/prettier-on-pr.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Prettier code formatter (Push)
name: Prettier code formatter

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
workflow_dispatch:

jobs:
check:
Expand Down

0 comments on commit 27d2fa0

Please sign in to comment.