fix: 修复备份文件处理逻辑,确保正确提交混淆后的代码和备份文件

This commit is contained in:
cmliu
2025-06-16 19:29:00 +08:00
parent bd0ccea4e3
commit 75f78b85c6
2 changed files with 10 additions and 13 deletions

View File

@@ -27,10 +27,11 @@ jobs:
echo "备份文件 _worker.js.backup 不存在,正在创建..."
cp _worker.js _worker.js.backup
fi
cp _worker.js.backup _worker_temp.js
- name: 混淆代码
run: |
javascript-obfuscator _worker.js.backup --output _worker.js \
javascript-obfuscator _worker_temp.js --output _worker.js \
--compact true \
--control-flow-flattening true \
--control-flow-flattening-threshold 1 \
@@ -48,14 +49,12 @@ jobs:
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add _worker.js
if git diff --cached --quiet _worker.js.backup; then
echo "_worker.js.backup 文件没有更改,跳过提交"
git add _worker.js _worker.js.backup
if git diff --cached --quiet; then
echo "没有文件更改,跳过提交"
else
echo "_worker.js.backup 文件有更改,添加到提交"
git add _worker.js.backup
git commit -m "混淆 _worker.js 文件并备份原文件"
fi
git commit -m "混淆 _worker.js 文件并备份原文件" || echo "没有需要提交的更改"
- name: 推送更改
uses: ad-m/github-push-action@master

View File

@@ -52,14 +52,12 @@ jobs:
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add _worker.js
if git diff --cached --quiet _worker.js.backup; then
echo "_worker.js.backup 文件没有更改,跳过提交"
git add _worker.js _worker.js.backup
if git diff --cached --quiet; then
echo "没有文件更改,跳过提交"
else
echo "_worker.js.backup 文件有更改,添加到提交"
git add _worker.js.backup
git commit -m "混淆 _worker.js 文件并备份原文件"
fi
git commit -m "混淆 _worker.js 文件并备份原文件" || echo "没有需要提交的更改"
- name: 推送更改
uses: ad-m/github-push-action@master