更新 .gitea/workflows/update-rules.yml
Some checks failed
Download and Push File / download-and-push (push) Failing after 35s
Some checks failed
Download and Push File / download-and-push (push) Failing after 35s
This commit is contained in:
@@ -1,76 +1,39 @@
|
|||||||
name: Download Clash Rules
|
name: Download and Push File
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
# 每天 UTC 2点执行 (北京时间10点)
|
|
||||||
- cron: '0 2 * * *'
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
branches: [ main, master ]
|
branches: [ main ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
download-rules:
|
download-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 检出仓库代码
|
# 1. 检出仓库
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.WORKFLOW_TOKEN }}
|
token: ${{ secrets.GITEA_TOKEN }} # 或使用 ${{ github.token }}
|
||||||
# 获取完整的提交历史,以便能够推送
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: 创建规则目录
|
# 2. 配置 Git
|
||||||
run: mkdir -p ruleset
|
- name: Configure Git
|
||||||
|
|
||||||
- name: 下载规则文件
|
|
||||||
run: |
|
run: |
|
||||||
# 下载所有规则文件
|
git config --local user.email "action@gitea.local"
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt" -o "ruleset/reject.txt"
|
git config --local user.name "Gitea Action"
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt" -o "ruleset/icloud.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt" -o "ruleset/apple.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt" -o "ruleset/google.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt" -o "ruleset/proxy.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt" -o "ruleset/direct.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt" -o "ruleset/private.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt" -o "ruleset/gfw.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/tld-not-cn.txt" -o "ruleset/tld-not-cn.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt" -o "ruleset/telegramcidr.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt" -o "ruleset/cncidr.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt" -o "ruleset/lancidr.txt"
|
|
||||||
curl -L "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt" -o "ruleset/applications.txt"
|
|
||||||
|
|
||||||
- name: 检查下载结果
|
# 3. 下载文件(示例)
|
||||||
|
- name: Download file
|
||||||
run: |
|
run: |
|
||||||
echo "=== 下载完成,文件列表 ==="
|
curl -o downloaded_file.txt https://example.com/file.txt
|
||||||
ls -la ruleset/
|
# 或者使用 wget
|
||||||
echo "=== 文件大小统计 ==="
|
# wget https://example.com/file.txt -O downloaded_file.txt
|
||||||
du -h ruleset/*
|
|
||||||
|
|
||||||
- name: 配置 Git 用户信息
|
# 4. 添加文件到 Git
|
||||||
|
- name: Add file to git
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "actions@gitea.com"
|
git add downloaded_file.txt
|
||||||
git config --local user.name "Gitea Actions Bot"
|
git commit -m "Add downloaded file via workflow"
|
||||||
|
|
||||||
- name: 检查是否有更改
|
# 5. 推送到仓库
|
||||||
id: check_changes
|
- name: Push changes
|
||||||
run: |
|
run: |
|
||||||
git add ruleset/
|
git push origin main
|
||||||
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 }}
|
|
||||||
Reference in New Issue
Block a user