Build & Release Aggregated Blocklists #142
This file contains hidden or 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: Build & Release Aggregated Blocklists | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # every night at midnight UTC | |
| workflow_dispatch: # manual trigger | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Generate aggregated lists | |
| run: python3 scripts/aggregate.py | |
| - name: Verify output files exist | |
| run: | | |
| mkdir -p releases | |
| if [ ! -f releases/aggregated-hosts.txt ] || [ ! -f releases/aggregated-dnsmasq.conf ] || [ ! -f releases/aggregated-adblock.txt ]; then | |
| echo "Error: One or more output files are missing!" | |
| exit 1 | |
| fi | |
| - name: Commit outputs | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add releases/ | |
| # only commit if there are changes | |
| git diff --quiet && echo "No changes to commit" || git commit -m "chore: update aggregated lists" | |
| git push | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # so tags and history are available | |
| persist-credentials: true # so we can push | |
| - name: Set release date | |
| run: echo "RELEASE_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
| - name: Check if tag exists | |
| id: tag_check | |
| run: | | |
| if git rev-parse "aggregated-${{ env.RELEASE_DATE }}" >/dev/null 2>&1; then | |
| echo "Tag aggregated-${{ env.RELEASE_DATE }} already exists" | |
| echo "tag_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Tag does not exist, will create it" | |
| echo "tag_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Git tag | |
| if: steps.tag_check.outputs.tag_exists == 'false' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag aggregated-${{ env.RELEASE_DATE }} | |
| git push origin aggregated-${{ env.RELEASE_DATE }} | |
| - name: Check if release exists | |
| id: release_check | |
| run: | | |
| if gh release view aggregated-${{ env.RELEASE_DATE }} >/dev/null 2>&1; then | |
| echo "Release aggregated-${{ env.RELEASE_DATE }} already exists" | |
| echo "release_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Release does not exist, will create it" | |
| echo "release_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| id: create_release | |
| if: steps.release_check.outputs.release_exists == 'false' | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: aggregated-${{ env.RELEASE_DATE }} | |
| release_name: Aggregated Lists ${{ env.RELEASE_DATE }} | |
| body: | | |
| This release contains the aggregated hosts, dnsmasq, and adblock blocklists for ${{ env.RELEASE_DATE }}. | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload release assets | |
| if: steps.release_check.outputs.release_exists == 'false' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| releases/aggregated-hosts.txt | |
| releases/aggregated-dnsmasq.conf | |
| releases/aggregated-adblock.txt | |
| tag_name: aggregated-${{ env.RELEASE_DATE }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |