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