Daily Release #19
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: Daily Release | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
if [ -f requirements.txt ]; then | |
pip install -r requirements.txt | |
fi | |
- name: Run scripts to generate lists and rules.json | |
run: | | |
python scripts/ip.py | |
python scripts/dns.py | |
python scripts/rules.py | |
- name: Delete existing release if it exists | |
uses: actions/github-script@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
script: | | |
try { | |
const tag = 'latest'; | |
const { data: releases } = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const release = releases.find(release => release.tag_name === tag); | |
if (release) { | |
console.log(`deleting release with tag: ${tag}`) | |
await github.rest.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release.id | |
}); | |
console.log(`deleted release with tag: ${tag}`) | |
} else { | |
console.log(`No release to delete for tag: ${tag}`) | |
} | |
} catch (error) { | |
console.error('Error deleting existing release:', error); | |
} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: latest | |
release_name: latest | |
draft: false | |
prerelease: false | |
body: | | |
Daily releases of **ip_blacklist.txt**, **dns_blacklist.txt**, and aggregated **rules.json** to feed the [Caddy WAF](https://github.com/fabriziosalmi/caddy-waf/). | |
- name: Upload Release Assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: lists/ip_blacklist.txt | |
asset_name: ip_blacklist.txt | |
asset_content_type: text/plain | |
- name: Upload Release Assets dns | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: lists/dns_blacklist.txt | |
asset_name: dns_blacklist.txt | |
asset_content_type: text/plain | |
- name: Upload Release Assets rules | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: rules/rules.json | |
asset_name: rules.json | |
asset_content_type: application/json |