Skip to content

Commit 9d60d28

Browse files
committed
Optimize comment-on-asciidoc-changes.yml
1 parent 71f641d commit 9d60d28

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

.github/workflows/comment-on-asciidoc-changes.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ name: Comment on PR for .asciidoc changes
33
on:
44
workflow_call: ~
55

6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
610
jobs:
711
comment-on-asciidoc-change:
812
runs-on: ubuntu-latest
913

1014
steps:
1115
- name: Checkout the repository
1216
uses: actions/checkout@v4
13-
with:
14-
fetch-depth: 0 # This is important to fetch all history
1517

16-
- name: Check for changes in .asciidoc files
18+
- name: Get changed files
1719
id: check-files
18-
run: |
19-
git fetch origin ${{ github.base_ref }}
20-
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E '\.asciidoc$'; then
21-
echo "asciidoc_changed=true" >> $GITHUB_OUTPUT
22-
else
23-
echo "asciidoc_changed=false" >> $GITHUB_OUTPUT
24-
fi
20+
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
21+
with:
22+
files: |
23+
**/*.asciidoc
24+
2525
- name: Add a comment if .asciidoc files changed
26-
if: steps.check-files.outputs.asciidoc_changed == 'true'
26+
if: steps.check-files.outputs.any_changed == 'true'
2727
uses: actions/github-script@v6
2828
with:
2929
script: |

0 commit comments

Comments
 (0)