diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a9e318e..b555124 100755 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,58 +1,72 @@ -name: build Rule - -on: - push: - branches: - - build - -jobs: - execute_python_script: - runs-on: ubuntu-latest - env: - TZ: Asia/Shanghai # UTC+8 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - - name: Execute Python script - run: | - git clone "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" -b build build - cd build - mkdir out - python main.py - cd out - mkdir Filters - cp -Rf AWAvenue-Ads-Rule-Adblock.txt AWAvenue-Ads-Rule.txt #历史遗留问题 - mv AWAvenue-Ads-Rule-* Filters/ - - - 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)" ]] || [[ "$(echo $(git status) | grep 'Untracked 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.event.head_commit.message }}" - git push --set-upstream origin main - fi - - - name: Purge jsdelivr CDN cache - run: | - cd push/Filters - echo "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/AWAvenue-Ads-Rule.txt" - curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/AWAvenue-Ads-Rule.txt" - for file in $(ls); do - echo "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/Filters/${file}" - curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/Filters/${file}" - done +name: build Rule + +on: + push: + branches: + - build + +jobs: + execute_python_script: + runs-on: ubuntu-latest + env: + TZ: Asia/Shanghai # UTC+8 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Execute Python script + run: | + git clone "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" -b build build + cd build + mkdir out + python main.py + cd out + mkdir Filters + cp -Rf AWAvenue-Ads-Rule-Adblock.txt AWAvenue-Ads-Rule.txt #历史遗留问题 + mv AWAvenue-Ads-Rule-* Filters/ + + - name: build mihomo mrs + run: | + cd build/out/Filters + wget -O ./mihomo.gz https://github.com/MetaCubeX/mihomo/releases/download/v1.19.12/mihomo-linux-amd64-v1.19.12.gz + gzip -d mihomo.gz + chmod +x mihomo + ./mihomo convert-ruleset domain yaml AWAvenue-Ads-Rule-Clash.yaml AWAvenue-Ads-Rule-Clash.mrs + rm -rf *mihomo* + + - name: Create AWAvenue-list.txt + run: | + cd build/out/Filters + ls | grep -v AWAvenue-list.txt > AWAvenue-list.txt + + - 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)" ]] || [[ "$(echo $(git status) | grep 'Untracked 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.event.head_commit.message }}" + git push --set-upstream origin main + fi + + - name: Purge jsdelivr CDN cache + run: | + cd push/Filters + echo "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/AWAvenue-Ads-Rule.txt" + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/AWAvenue-Ads-Rule.txt" + for file in $(ls); do + echo "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/Filters/${file}" + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@main/Filters/${file}" + done