Skip to content

Commit 83e6bdb

Browse files
authored
Update auto-version.yml
1 parent 9ce74e1 commit 83e6bdb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/auto-version.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,28 @@ jobs:
1717
id: timestamp
1818
run: echo "ts=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
1919

20-
- name: Replace version timestamp in .user.js files
20+
- name: Get changed .user.js files in last commit
21+
id: changed_files
2122
run: |
22-
FILES=$(find . -name "*.user.js")
23-
for file in $FILES; do
23+
FILES=$(git diff --name-only HEAD~1 | grep '\.user\.js$' || echo "")
24+
echo "files=$FILES" >> $GITHUB_OUTPUT
25+
26+
- name: Replace version timestamp in changed files only
27+
if: ${{ steps.changed_files.outputs.files != '' }}
28+
run: |
29+
echo "Changed files: ${{ steps.changed_files.outputs.files }}"
30+
for file in ${{ steps.changed_files.outputs.files }}; do
2431
echo "Updating $file"
2532
sed -i "s/\(cdn\.jsdelivr\.net\/.*\.user\.js?v=\)[0-9]\+/\1${{ steps.timestamp.outputs.ts }}/g" "$file"
2633
done
2734
2835
- name: Commit and push if changed
36+
if: ${{ steps.changed_files.outputs.files != '' }}
2937
run: |
3038
git config user.name "github-actions[bot]"
3139
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
3240
if [ -n "$(git status --porcelain)" ]; then
33-
git add .
41+
git add ${{ steps.changed_files.outputs.files }}
3442
git commit -m "Auto update @updateURL ?v=${{ steps.timestamp.outputs.ts }}"
3543
git push
3644
else

0 commit comments

Comments
 (0)