Skip to content

main.user.js version update #9

main.user.js version update

main.user.js version update #9

name: main.user.js version update
on:
schedule:
- cron: "0 16 * * 0"
workflow_dispatch:
jobs:
update_version:
if: ${{ !startsWith(github.event.client_payload.head_commit.message, 'main.user.js Update to version') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.CI_GITHUB_TOKEN }} # 要绕过分支保护规则此处不可少
- name: Get latest tag commit SHA
run: echo "LATEST_TAG_COMMIT_SHA=$(git rev-list --tags --max-count=1)" >> $GITHUB_ENV
- name: Get current commit SHA
run: echo "CURRENT_COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Check if commit is ahead of latest tag
run: |
if [ "$CURRENT_COMMIT_SHA" != "$LATEST_TAG_COMMIT_SHA" ]; then
echo "AHEAD=true" >> $GITHUB_ENV
else
echo "AHEAD=false" >> $GITHUB_ENV
fi
- name: Update version in main.user.js
if: ${{ env.AHEAD == 'true' }}
run: |
sed -i "s/@version\s*[^\\s]*/@version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" main.user.js
- name: Commit and push main.user.js
if: ${{ env.AHEAD == 'true' }}
run: |
bash script/ci.sh \
${{ secrets.CI_GITHUB_TOKEN }} \
"maboloshi/github-chinese" \
"main.user.js" \
"main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')"
"Signed-off-by: 沙漠之子 <[email protected]>"