Skip to content

5whys-Ad-list-processing #5560

5whys-Ad-list-processing

5whys-Ad-list-processing #5560

Workflow file for this run

name: 5whys-Ad-list-processing
on:
workflow_dispatch:
watch:
types: [started]
schedule:
- cron: 21 */3 * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go 1.x.y
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '12.x'
- run: npm install
- name: Install hostlist-complier
run: npm i -g @adguard/hostlist-compiler
- name: Set folder condition, variables and timezone
run: |
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
rm -f ./out*.txt
- name: Run main.go
run: |
go run main.go "./setting/super_rules.txt" out_super.txt "./setting/custom.txt"
go run main.go "./setting/full_rules.txt" out_full.txt "./setting/custom.txt"
go run main.go "./setting/medium_rules.txt" out_med.txt "./setting/custom.txt"
go run main.go "./setting/min_rules.txt" out_min.txt "./setting/custom.txt"
- name: Create output_super.txt
run: |
line=$(wc -l < out_super.txt)
echo "# Title: 5whys SUPER block Adguard Home Rules List (Use with a lot of false rejects)" > output_super.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_super.txt
echo "# Expires: around 1 day" >> output_super.txt
echo "# Total number of rules = $line" >> output_super.txt
echo "# Below are the links of the adblock rules" >> output_super.txt
while IFS= read -r line; do echo "# $line" >> output_super.txt; done < "./setting/super_rules.txt"
echo "####################################################################################" >> output_super.txt
cat out_super.txt >> output_super.txt
echo "####################################################################################" >> output_super.txt
- name: Create output_full.txt
run: |
line=$(wc -l < out_full.txt)
echo "# Title: 5whys Full block Adguard Home Rules List" > output_full.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_full.txt
echo "# Expires: around 1 day" >> output_full.txt
echo "# Total number of rules = $line" >> output_full.txt
echo "# Below are the links of the adblock rules" >> output_full.txt
while IFS= read -r line; do echo "# $line" >> output_full.txt; done < "./setting/full_rules.txt"
echo "####################################################################################" >> output_full.txt
cat out_full.txt >> output_full.txt
echo "####################################################################################" >> output_full.txt
- name: Create output_medium.txt
run: |
line=$(wc -l < out_med.txt)
echo "# Title: 5whys Medium Adguard Home Rules List" > output_medium.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_medium.txt
echo "# Expires: around 1 day" >> output_medium.txt
echo "# Total number of rules = $line" >> output_medium.txt
echo "# Below are the links of the adblock rules" >> output_medium.txt
while IFS= read -r line; do echo "# $line" >> output_medium.txt; done < "./setting/medium_rules.txt"
echo "####################################################################################" >> output_medium.txt
cat out_med.txt >> output_medium.txt
echo "####################################################################################" >> output_medium.txt
- name: Create output_min.txt
run: |
line=$(wc -l < out_min.txt)
echo "# Title: 5whys Min Adguard Home Rules List" > output_min.txt
echo "# Verison: $(date +%Y%m%d%H%M)" >> output_min.txt
echo "# Expires: around 1 day" >> output_min.txt
echo "# Total number of rules = $line" >> output_min.txt
echo "# Below are the links of the adblock rules" >> output_min.txt
while IFS= read -r line; do echo "# $line" >> output_min.txt; done < "./setting/min_rules.txt"
echo "####################################################################################" >> output_min.txt
cat out_min.txt >> output_min.txt
echo "####################################################################################" >> output_min.txt
- name: move output file
run: |
mkdir -p ./publish/
cp ./output*.txt ./publish/
cp ./output*.txt ./rules/
- name: Release and upload assets
uses: softprops/action-gh-release@v0.1.6
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
./publish/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "121651775+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin release
- name: Purge jsdelivr CDN
run: |
cd publish || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
- name: Commit *.txt
run: |
echo `date +"%Y-%m-%d %H:%M:%S"` ZJC CKC >> ./rules/date.log
git config --global user.email ${{ secrets.EMAIL }}
git config --global user.name ${{ secrets.NAME }}
git add ./rules/output* ./rules/date.log
git commit -m "${{ env.RELEASE_NAME }}"
git push