AWAvenue-Ads-Rule/.github/workflows/build.yaml

66 lines
1.9 KiB
YAML

name: build Rule
on:
push:
branches:
- main
jobs:
execute_python_script:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2.5.0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Execute Python script
run: |
cd build
mkdir out
python main.py
cd out
mkdir Filters
mv AWAvenue-Ads-Rule-Adguard.txt AWAvenue-Ads-Rule.txt #历史遗留问题
mv AWAvenue-Ads-Rule-* Filters/
cd Filters
wget -O ./sing-box.tar.gz https://github.com/SagerNet/sing-box/releases/download/v1.8.2/sing-box-1.8.2-Android-arm64.tar.gz
tar -xzvf sing-box.tar.gz
chmod +x */sing-box
./*/sing-box rule-set compile AWAvenue-Ads-Rule-Singbox.json
./*/sing-box rule-set compile AWAvenue-Ads-Rule-Singbox-regex.json
rm -rf *sing-box*
ls
- name: Git push
run: |
git clone "https://${{ github.actor }}:${{ secrets.TOKEN }}@github.com/${{ github.repository }}" push
cp -Rf build/out/* push/
cd push
files=$(find . -name '*AWAvenue*')
echo $files
if [[ -n "$(git diff -- $files)" ]]; then
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add AWAvenue-Ads-Rule.txt
cd Filters
git add *AWAvenue*
git commit -m "github action build rule"
git push --set-upstream origin main
fi
- name: Purge jsdelivr CDN
run: |
cd push
files=$(find . -name '*AWAvenue*')
if [[ -n "$(git diff -- $files)" ]]; then
for file in $files; do
url=$(echo $file | sed "s/\.//g")
curl -L -v "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/${url}"
done
fi