Skip to content

Commit a21c91c

Browse files
committed
Improve comment tags for PR comments
1 parent fc81ea2 commit a21c91c

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.github/actions/ensure-no-diff/action.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Ensure no changes to tracked files
22
description: Detect any changes to tracked files and fail the forkflow.
33
inputs:
4-
post-pr-comment:
5-
description: Post a comment with changes (only on pull requests)
4+
pr-comment-tag:
5+
description: |
6+
If specified, post a comment with changes (only on pull requests).
7+
Comments matching this tag will be edited or deleted on subsequent runs.
68
required: false
7-
default: true
9+
default: ""
810
comment-header:
911
description: Header for the PR comment
1012
required: false
@@ -23,14 +25,15 @@ runs:
2325
shell: bash
2426
run: git diff --diff-algorithm=histogram --exit-code
2527

26-
- name: Post PR comment
28+
- name: Update PR comment
2729
if: >-
2830
failure() &&
31+
steps.git-diff.conclusion == 'failure' &&
2932
github.event_name == 'pull_request' &&
30-
inputs.post-pr-comment == 'true'
33+
inputs.pr-comment-tag != ''
3134
uses: thollander/actions-comment-pull-request@v3
3235
with:
33-
comment-tag: ${{ github.job }}
36+
comment-tag: ${{ inputs.comment-tag }}
3437
mode: recreate
3538
message: |
3639
${{ inputs.comment-header }}

.github/workflows/build.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v5
1919
with:
20-
fetch-tags: true # Required for dynamic version
20+
# Required for dynamic version
21+
fetch-depth: 0
22+
fetch-tags: true
2123

2224
- uses: actions/setup-python@v6
2325
with:
@@ -41,6 +43,8 @@ jobs:
4143

4244
- name: Ensure no changes to tracked files
4345
uses: ./.github/actions/ensure-no-diff
46+
with:
47+
pr-comment-tag: ${{ github.job }}
4448

4549
wheels:
4650
name: Binary wheels
@@ -57,7 +61,9 @@ jobs:
5761
steps:
5862
- uses: actions/checkout@v5
5963
with:
60-
fetch-tags: true # Required for dynamic version
64+
# Required for dynamic version
65+
fetch-depth: 0
66+
fetch-tags: true
6167

6268
- uses: actions/setup-python@v6
6369
with:
@@ -88,3 +94,5 @@ jobs:
8894

8995
- name: Ensure no changes to tracked files
9096
uses: ./.github/actions/ensure-no-diff
97+
with:
98+
pr-comment-tag: ${{ github.job }}/${{matrix.os}}

0 commit comments

Comments
 (0)