main.user.js version update #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- 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 | |
git diff --quiet --exit-code README.md || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV | |
- 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 }} \ | |
"maboloshi/github-chinese" \ | |
"main.user.js" \ | |
"main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" \ | |
"Signed-off-by: 沙漠之子 <7850715+maboloshi@users.noreply.github.com>" |