Merge branch 'main' of https://github.com/Aethersailor/Custom_OpenCla… #13
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 Modify Custom_Clash.ini | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- cfg/Custom_Clash.ini # 当 Custom_Clash.ini 文件更新时触发 | |
workflow_dispatch: # 添加手动触发事件 | |
jobs: | |
sync-and-modify: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: 检出源仓库 | |
- name: Checkout Source Repo | |
uses: actions/checkout@v3 | |
# Step 2: 克隆目标仓库 | |
- name: Clone Target Repo | |
run: | | |
git clone https://github.com/Aethersailor/Custom_Clash_Rules.git target-repo | |
cd target-repo | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
# Step 3: 修改文件 | |
- name: Modify File | |
run: | | |
# 复制文件到目标仓库 | |
cp cfg/Custom_Clash.ini target-repo/cfg/Custom_Clash_Full.ini | |
# 进入目标仓库 | |
cd target-repo | |
# 删除 [custom] 之前的内容(保留 [custom] 行本身) | |
sed -i '1,/^\[custom\]/ { /^[[]custom[]]/!d }' cfg/Custom_Clash_Full.ini | |
# 添加内容到文件开头并加两个空行 | |
sed -i '1i ;Custom_Clash_Rules\n;全分组防 DNS 泄漏订阅转换模板\n;作者:https://github.com/Aethersailor\n;项目地址:https://github.com/Aethersailor/Custom_Clash_Rules\n;该订阅模板为 Custom_OpenClash_Rules 项目的衍生项目\n;基于 ACL4SSR 模板魔改而来,感谢原作者!\n\n' cfg/Custom_Clash_Full.ini | |
# 删除包含 "GEOSITE,cn" 和 "GEOIP,cn" 字样的行 | |
sed -i '/GEOSITE,cn/d' cfg/Custom_Clash_Full.ini | |
sed -i '/GEOIP,cn/d' cfg/Custom_Clash_Full.ini | |
# 在包含 "Custom_Proxy" 的行后添加两行内容 | |
sed -i '/Custom_Proxy/a ruleset=🎯 全球直连,[]GEOSITE,cn\nruleset=🎯 全球直连,[]GEOIP,cn,no-resolve' cfg/Custom_Clash_Full.ini | |
# Step 4: 提交更改到目标仓库 | |
- name: Commit and Push Changes | |
run: | | |
cd target-repo | |
git add . | |
git commit -m "Update Custom_Clash_Full.ini based on Custom_Clash.ini" | |
git push https://[email protected]/Aethersailor/Custom_Clash_Rules.git main | |
env: | |
TARGET_REPO_TOKEN: ${{ secrets.TARGET_REPO_TOKEN }} |