Skip to content

main(greasyfork).user.js and locals(greasyfork).js update #2

main(greasyfork).user.js and locals(greasyfork).js update

main(greasyfork).user.js and locals(greasyfork).js update #2

name: main(greasyfork).user.js and locals(greasyfork).js update
on:
schedule:
# 每周五的UTC时间16点(北京时间凌晨0点)
- cron: "0 16 * * 4"
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync update locals(greasyfork).js
run: |
# 获得最近以`main.user.js Update to version`开头的提交的引用
ref=$(git log --grep="^main.user.js Update to version" -n 1 --pretty=format:"%H")
# 从该提交中提取文件`locals.js`并覆写到本地文件`locals(greasyfork).js`
git show $ref:locals.js > "locals(greasyfork).js"
git diff --quiet --exit-code "locals(greasyfork).js" || \
echo "LOCALS_JS_IS_CHANGED=true" >> $GITHUB_ENV
- name: Update version in main(greasyfork).user.js
if: |
${{ env.LOCALS_JS_IS_CHANGED == 'true' }}
run: |
sed -i -E "s/(@version\s*[0-9]+\.[0-9]+\.[0-9]+)(-[0-9]{4}-[0-9]{2}-[0-9]{2})?/\
\1-$(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" "main(greasyfork).user.js"
git diff --quiet --exit-code "main(greasyfork).user.js" || \
echo "MAIN_USER_JS_IS_CHANGED=true" >> $GITHUB_ENV
- name: Commit and push locals(greasyfork).js and main(greasyfork).user.js
if: ${{ env.LOCALS_JS_IS_CHANGED == 'true' &&
env.MAIN_USER_JS_IS_CHANGED == 'true' }}
run: |
bash script/ci_commit_with_signature.sh \
-T "${{ secrets.CI_GITHUB_TOKEN }}" \
-R "${{ github.repository }}" \
-B "${{ github.ref_name }}" \
-P "${{ github.sha }}" \
-F "locals(greasyfork).js, main(greasyfork).user.js" \
-h "main(greasyfork).user.js Update on $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" \
-b "Signed-off-by: 沙漠之子 <[email protected]>"