Run_Adblock_Reject_DOMAIN_TXT #7400
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: Run_Adblock_Reject_DOMAIN_TXT # 工作流名称 | |
on: | |
schedule: | |
- cron: '*/20 * * * *' # 每20分钟运行一次 | |
workflow_dispatch: # 允许手动触发工作流 | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 使用最新的 Ubuntu 版本作为运行环境 | |
steps: | |
- name: Setup Node.js 20 # 设置 Node.js 20 环境 | |
uses: actions/setup-node@v3 # 使用官方的 setup-node 操作来设置 Node.js 环境 | |
with: | |
node-version: '20' # 指定使用 Node.js 版本 20 | |
- name: Checkout repository # 检出代码仓库 | |
uses: actions/checkout@v3 # 使用官方的 checkout 操作来检出代码 | |
- name: Install PowerShell 7 # 安装 PowerShell 7 | |
run: | | |
sudo apt-get update # 更新包列表 | |
sudo apt-get install -y wget apt-transport-https software-properties-common # 安装必要的包 | |
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb # 下载微软的包配置文件 | |
sudo dpkg -i packages-microsoft-prod.deb # 安装包配置文件 | |
sudo apt-get update # 更新包列表 | |
sudo apt-get install -y powershell # 安装 PowerShell 7 | |
rm packages-microsoft-prod.deb # 删除包配置文件 | |
- name: Run adblock_rule_generator_domain_txt.ps1 # 运行 adblock_rule_generator_domain_txt.ps1 脚本 | |
run: pwsh -File ./adblock_rule_generator_domain_txt.ps1 # 使用 PowerShell 7 运行脚本 | |
- name: Force Add and Commit Txt file # 强制添加并提交 adblock_reject_domain.txt 文件 | |
run: | | |
git config --global user.name 'github-actions' # 配置提交用户名 | |
git config --global user.email '[email protected]' # 配置提交邮箱 | |
git add -f adblock_reject_domain.txt # 强制添加 adblock_reject_domain.txt 文件 | |
git commit -m 'Update adblock_reject_domain.txt' || git commit --allow-empty -m 'Empty commit to force push' # 提交更改,若无更改则提交空更改 | |
- name: Retry Push Txt file # 推送 adblock_reject_domain.txt 文件,失败时重试 | |
env: | |
TOKEN: ${{ secrets.TOKEN }} # 使用 GitHub 密钥进行身份验证 | |
run: | | |
for i in {1..5}; do # 尝试最多5次 | |
git push --force origin HEAD && exit 0 || (echo "Push failed, retrying in 10 seconds..." && sleep 10) | |
done |