diff --git a/.github/workflows/locals(greasyfork).js_update.yaml b/.github/workflows/locals(greasyfork).js_update.yaml index a137fd50d..57678c4fe 100644 --- a/.github/workflows/locals(greasyfork).js_update.yaml +++ b/.github/workflows/locals(greasyfork).js_update.yaml @@ -26,8 +26,14 @@ jobs: 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_js_time=$(git log -1 --format=%at $ref -- locals.js) + echo "locals_js_time=$locals_js_time" >> $GITHUB_ENV + # 从该提交中提取文件`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 @@ -35,8 +41,10 @@ jobs: if: | ${{ env.LOCALS_JS_IS_CHANGED == 'true' }} run: | + # 使用`locals.js`的文件日期为词库版本号 + locals_js_date=$(TZ='Asia/Shanghai' date -d "@${{ env.locals_js_time }}" +'%Y-%m-%d') 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" + \1-$locals_js_date/" "main(greasyfork).user.js" git diff --quiet --exit-code "main(greasyfork).user.js" || \ echo "MAIN_USER_JS_IS_CHANGED=true" >> $GITHUB_ENV