Sync and Process Files #383
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync and Process Files | |
on: | |
schedule: | |
- cron: '0 23 * * *' | |
workflow_dispatch: | |
jobs: | |
sync-and-process: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout your repo | |
uses: actions/checkout@v4 | |
with: | |
repository: lainbo/gists-hub | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: gists-hub | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Generate QuantumultX de-advertising files | |
run: | | |
# 创建存放需要处理格式文件的目标文件夹 | |
mkdir -p gists-hub/src/QuantumultX/List/RemoteAdRules gists-hub/src/QuantumultX/List/RemoteOtherRules | |
# 下载文件 | |
curl -o gists-hub/src/QuantumultX/List/RemoteAdRules/BanAD.list https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanAD.list | |
curl -o gists-hub/src/QuantumultX/List/RemoteAdRules/BanEasyList.list https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanEasyList.list | |
curl -o gists-hub/src/QuantumultX/List/RemoteAdRules/BanEasyListChina.list https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanEasyListChina.list | |
curl -o gists-hub/src/QuantumultX/List/RemoteOtherRules/GoogleCNProxyIP.list https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/GoogleCNProxyIP.list | |
cd gists-hub | |
sed -i '/^DOMAIN/{s/^DOMAIN/HOST/; s/$/,Advertising/}' src/QuantumultX/List/RemoteAdRules/*.list | |
sed -i '/^IP-CIDR.*no-resolve/s/no-resolve/Advertising,&/' src/QuantumultX/List/RemoteAdRules/*.list | |
sed -i '/^IP-CIDR.*no-resolve/s/no-resolve/Proxy,&/' src/QuantumultX/List/RemoteOtherRules/GoogleCNProxyIP.list | |
echo "已经将广告规则文件处理为QuantumultX可用的格式" | |
- name: Generate CustomDirectApp.list and Clash YAML | |
run: | | |
cd gists-hub | |
npm run generateDirectAppList | |
echo "已生成 CustomDirectApp.list 文件" | |
npm run generateClashYaml | |
echo "已生成 Clash YAML 文件" | |
- name: Commit and push changes | |
run: | | |
cd gists-hub | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
if git diff --staged --quiet; then | |
echo "文件与上游仓库相同,不需要提交,任务结束。" | |
else | |
echo "检测到文件变化,正在创建提交..." | |
git commit -m "Automatic synchronization of rule lists" | |
git push | |
echo "提交完成,任务结束。" | |
fi |