Skip to content

Commit 76c8474

Browse files
committed
Update update_version.yml
1 parent 6d6ae24 commit 76c8474

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/update_version.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,48 @@ on:
44
paths:
55
- 'Pagetual/items_all.json'
66
- 'Pagetual/pagetualRules.json'
7+
workflow_run:
8+
workflows: ["Collect wedata for pagetual"]
9+
types:
10+
- completed
711

812
jobs:
913
update_version:
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout repository
13-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1420

15-
- name: Read current version
16-
id: read_version
17-
run: echo "::set-output name=version::$(cat Pagetual/version)"
21+
- name: Check file modification timestamps
22+
id: check_file_timestamps
23+
run: |
24+
version_timestamp=$(git log -1 --format="%at" Pagetual/version)
25+
items_all_timestamp=$(git log -1 --format="%at" Pagetual/items_all.json)
26+
pagetualRules_timestamp=$(git log -1 --format="%at" Pagetual/pagetualRules.json)
27+
if [[ $version_timestamp < $items_all_timestamp || $version_timestamp < $pagetualRules_timestamp ]]; then
28+
version=$(cat Pagetual/version)
29+
else
30+
version=0
31+
echo "Version file is not updated. Skipping version read."
32+
fi
33+
echo "VERSION=$version" >> $GITHUB_ENV
1834
1935
- name: Increment version
36+
if: env.VERSION != '0'
2037
id: increment_version
21-
run: echo "::set-output name=version::$((${{ steps.read_version.outputs.version }} + 1))"
38+
run: echo "VERSION=$((VERSION + 1))" >> $GITHUB_ENV
2239

2340
- name: Update version file
24-
run: echo "${{ steps.increment_version.outputs.version }}" > Pagetual/version
41+
if: env.VERSION != '0'
42+
run: echo $VERSION > Pagetual/version
2543

2644
- name: Commit version update
45+
if: env.VERSION != '0'
2746
run: |
2847
git config --local user.email "rixixi@gmail.com"
2948
git config --local user.name "hoothin-update"
3049
git add Pagetual/version
31-
git commit -m "Update version of Pagetual rules to ${{ steps.increment_version.outputs.version }}"
50+
git commit -m "Update version of Pagetual rules to $VERSION"
3251
git push https://${{ secrets.ACTION_SECRET }}@github.com/${{ github.repository }}

0 commit comments

Comments
 (0)