Debian Codegraph @

.github/workflows/diff_shades_comment.yml

raw
1 name: diff-shades comment
2
3 on:
4 workflow_run:
5 workflows: [diff-shades]
6 types: [completed]
7
8 permissions: {}
9
10 jobs:
11 comment:
12 runs-on: ubuntu-latest
13 # We want to comment even if there were failed files or the stable style changed
14 # That would cause the main workflow to "fail"
15 if:
16 github.event.workflow_run.event == 'pull_request' &&
17 contains(fromJSON('["success", "failure"]'), github.event.workflow_run.conclusion)
18 permissions:
19 pull-requests: write # Needed to comment on PR
20 steps:
21 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22 with:
23 persist-credentials: false
24
25 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
26 id: artifacts
27 with:
28 merge-multiple: true
29 pattern: ".*.pr-comment.md"
30 github-token: ${{ github.token }}
31 run-id: ${{ github.event.workflow_run.id }}
32
33 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
34 with:
35 python-version: "3.13"
36 pip-version: "25.3"
37 pip-install: --group diff-shades-comment
38
39 - name: Get PR number
40 id: pr
41 run:
42 echo pr=$(gh pr list --search $sha --json number --jq ".[0].number") >>
43 "$GITHUB_OUTPUT"
44 env:
45 GITHUB_TOKEN: ${{ github.token }}
46 sha: ${{ github.event.workflow_run.head_sha }}
47
48 - name: Get details from initial workflow run
49 id: metadata
50 run: |
51 python scripts/diff_shades_gha_helper.py comment-details \
52 $pr $run_id $(echo .*.pr-comment.md)
53 env:
54 GITHUB_TOKEN: ${{ github.token }}
55 pr: ${{ steps.pr.outputs.pr }}
56 run_id: ${{ github.event.workflow_run.id }}
57
58 - name: Try to find pre-existing PR comment
59 id: find-comment
60 uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
61 with:
62 issue-number: ${{ steps.pr.outputs.pr }}
63 comment-author: "github-actions[bot]"
64 body-includes: "diff-shades"
65
66 - name: Create or update PR comment
67 uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
68 with:
69 comment-id: ${{ steps.find-comment.outputs.comment-id }}
70 issue-number: ${{ steps.pr.outputs.pr }}
71 body: ${{ steps.metadata.outputs.comment-body }}
72 edit-mode: replace