-
Notifications
You must be signed in to change notification settings - Fork 411
50 lines (45 loc) · 1.81 KB
/
main.user.js_version_update.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: main.user.js version update
on:
schedule:
- cron: "0 16 * * 0"
workflow_dispatch:
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if commit is ahead of latest tag
run: |
LATEST_TAG_COMMIT_SHA=$(git rev-list --tags --max-count=1)
LAST_COMMIT_SHA=${{ github.sha }}
if [ "$LAST_COMMIT_SHA" != "$LATEST_TAG_COMMIT_SHA" ]; then
echo "AHEAD=true" >> $GITHUB_ENV
else
echo "AHEAD=false" >> $GITHUB_ENV
fi
- name: Get last commit message
run: |
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
echo "LAST_COMMIT_MESSAGE=$LAST_COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Update version in main.user.js
if: |
${{ env.AHEAD == 'true' }} &&
${{ !startsWith(env.LAST_COMMIT_MESSAGE, 'main.user.js Update to version') }}
run: |
sed -i "s/@version\s*[^\\s]*/@version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" main.user.js
git diff --quiet --exit-code main.user.js || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
git diff main.user.js
echo "env.CHANGES_DETECTED=" ${{ env.CHANGES_DETECTED }}
cat main.user.js
- name: Commit and push main.user.js
if: ${{ env.AHEAD == 'true' && env.CHANGES_DETECTED == 'true' }}
run: |
bash script/ci_commit_with_signature.sh \
${{ secrets.CI_GITHUB_TOKEN }} \
${{ github.repository }} \
${{ github.ref_name }} \
${{ github.sha }} \
"main.user.js" \
"main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" \
"Signed-off-by: 沙漠之子 <[email protected]>"