diff --git a/.github/workflows/prettier-comment-on-pr.yml b/.github/workflows/prettier-comment-on-pr.yml index 6490006d5c8f..fead902e5916 100644 --- a/.github/workflows/prettier-comment-on-pr.yml +++ b/.github/workflows/prettier-comment-on-pr.yml @@ -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. diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 3a58ec0989df..b55e00f3507c 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -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 }}"}'