|
4 | 4 | paths: |
5 | 5 | - 'Pagetual/items_all.json' |
6 | 6 | - 'Pagetual/pagetualRules.json' |
| 7 | + workflow_run: |
| 8 | + workflows: ["Collect wedata for pagetual"] |
| 9 | + types: |
| 10 | + - completed |
7 | 11 |
|
8 | 12 | jobs: |
9 | 13 | update_version: |
10 | 14 | runs-on: ubuntu-latest |
11 | 15 | steps: |
12 | 16 | - name: Checkout repository |
13 | | - uses: actions/checkout@v2 |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
14 | 20 |
|
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 |
18 | 34 |
|
19 | 35 | - name: Increment version |
| 36 | + if: env.VERSION != '0' |
20 | 37 | id: increment_version |
21 | | - run: echo "::set-output name=version::$((${{ steps.read_version.outputs.version }} + 1))" |
| 38 | + run: echo "VERSION=$((VERSION + 1))" >> $GITHUB_ENV |
22 | 39 |
|
23 | 40 | - 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 |
25 | 43 |
|
26 | 44 | - name: Commit version update |
| 45 | + if: env.VERSION != '0' |
27 | 46 | run: | |
28 | 47 | git config --local user.email "rixixi@gmail.com" |
29 | 48 | git config --local user.name "hoothin-update" |
30 | 49 | 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" |
32 | 51 | git push https://${{ secrets.ACTION_SECRET }}@github.com/${{ github.repository }} |
0 commit comments