From 58b0565dc4bddedb8b8d939ed0ff81f88a41162b Mon Sep 17 00:00:00 2001 From: adminroot Date: Thu, 11 Sep 2025 23:03:34 -0700 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/update-ru?= =?UTF-8?q?les.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/update-rules.yml | 40 ++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/update-rules.yml b/.gitea/workflows/update-rules.yml index 2a15f97..f7e3252 100644 --- a/.gitea/workflows/update-rules.yml +++ b/.gitea/workflows/update-rules.yml @@ -13,6 +13,14 @@ jobs: runs-on: ubuntu-latest steps: + # 检出仓库代码 + - name: Checkout repository + uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + # 获取完整的提交历史,以便能够推送 + fetch-depth: 0 + - name: 创建规则目录 run: mkdir -p ruleset @@ -40,9 +48,29 @@ jobs: echo "=== 文件大小统计 ===" du -h ruleset/* - - name: 上传规则文件 - uses: actions/upload-artifact@v3 - with: - name: clash-rules-$(date +%Y%m%d) - path: ruleset/ - retention-days: 30 \ No newline at end of file + - name: 配置 Git 用户信息 + run: | + git config --local user.email "actions@gitea.com" + git config --local user.name "Gitea Actions Bot" + + - name: 检查是否有更改 + id: check_changes + run: | + git add ruleset/ + if git diff --staged --quiet; then + echo "has_changes=false" >> $GITHUB_OUTPUT + echo "没有检测到文件更改" + else + echo "has_changes=true" >> $GITHUB_OUTPUT + echo "检测到文件更改" + fi + + - name: 提交更改 + if: steps.check_changes.outputs.has_changes == 'true' + run: | + git commit -m "🔄 Update Clash rules [$(date +'%Y-%m-%d %H:%M:%S')]" + + - name: 推送到仓库 + if: steps.check_changes.outputs.has_changes == 'true' + run: | + git push origin HEAD:${{ github.ref_name }} \ No newline at end of file