Update uBlacklist subscription weekly #1138
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: Update uBlacklist subscription weekly | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
#if: github.event.repository.owner.id == github.event.sender.id | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '>=1.17.0' | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
- name: Merge txt | |
run: | | |
# 预处理一些数据 | |
cp source/gyli/Blocklist/BLOCKLIST_uBlacklist source/gyli/Blocklist/blocklist.txt | |
rm uBlacklist.txt | |
rm uBlocklist.txt | |
rm tools/uBlacklist_backup.txt | |
rm source/gyli/Blocklist/blocklist.txt | |
rm source/Paxxs/Google-Blocklist/data -rf | |
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/additional_list_nuclear.txt | |
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/list.txt | |
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/list_uBlacklist_nuclear.txt | |
rm source/laylavish/uBlockOrigin-HUGE-AI-Blocklist/noai_hosts.txt | |
mv reverse_url.txt tools/reverse_url | |
# 合并所有列表 | |
find . -type f -name "*.txt" -exec sh -c 'cat "$0"; echo' {} \; > tools/uBlacklist | |
# Issue # 48 | |
sed -i '/^http:\/\//d' source/zweie/some-rules-for-ublacklist/Annoyingbastard.txt | |
cd tools | |
mv uBlacklist uBlacklist.txt | |
go run main.go | |
cat -s uBlacklist.txt | sed '/^[[:space:]]*$/d' | |
mv uBlacklist.txt ../uBlacklist.txt -f | |
cd .. | |
# 删除以 # 开头的行 | |
sed -i '/^#/d' uBlacklist.txt | |
# 删除以 ! 开头的行 | |
sed -i '/^!/d' uBlacklist.txt | |
cat tools/reverse_url >> uBlacklist.txt | |
# 添加时间 | |
sed -i "1i\! Update weekly at $(TZ=UTC-8 date +'%Y-%m-%d %T %z')" uBlacklist.txt | |
# 去除空行 | |
sed -i '/^$/d' uBlacklist.txt | |
ln -s uBlacklist.txt uBlocklist.txt | |
# 获取当前时间存入环境变量 | |
echo "CURRENT_TIME=$(TZ=UTC-8 date +'%Y-%m-%d %T %z')" >> $GITHUB_ENV | |
- name: Commit files | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "ci(build): update weekly at ${{ env.CURRENT_TIME }}" | |
committer_name: 'github-actions[bot]' | |
committer_email: 'github-actions[bot]@users.noreply.github.com' | |
add: | | |
'uBlacklist.txt' | |
'tools/uBlacklist_backup.txt' |