From 7b2fbf079c6622e84fa8b5b0404408b7c2b21ea7 Mon Sep 17 00:00:00 2001 From: adminroot Date: Thu, 11 Sep 2025 22:48:43 -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..40c42be 100644 --- a/.gitea/workflows/update-rules.yml +++ b/.gitea/workflows/update-rules.yml @@ -13,6 +13,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: 检出代码 + uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + - name: 创建规则目录 run: mkdir -p ruleset @@ -40,9 +45,32 @@ 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 --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: 提交并推送规则文件 + run: | + # 添加所有文件到暂存区 + git add ruleset/ + + # 检查是否有更改 + if git diff --staged --quiet; then + echo "没有检测到文件更改,跳过提交" + else + # 提交更改 + git commit -m "Auto update clash rules - $(date +%Y-%m-%d)" + + # 推送到仓库 + git push origin ${{ github.ref_name }} + echo "规则文件已成功推送到仓库" + fi + + - name: 创建发布标签 (可选) + if: github.event_name == 'schedule' + run: | + TAG_NAME="rules-$(date +%Y%m%d-%H%M%S)" + git tag $TAG_NAME + git push origin $TAG_NAME + echo "已创建标签: $TAG_NAME" \ No newline at end of file