Update Domain Lists #151
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: Update Domain Lists | |
| on: | |
| schedule: | |
| - cron: "0 */4 * * *" # Every 4 hours | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write # Required for PyPI trusted publishing | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Need full history for hatch-vcs and tag detection | |
| - name: Download latest domain lists | |
| run: | | |
| curl -sL https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt \ | |
| -o disposable_email/domains.txt | |
| curl -sL https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains_strict.txt \ | |
| -o disposable_email/domains_strict.txt | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up Python | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install and test | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| pip install -e ".[test]" | |
| pytest tests/ -v | |
| - name: Commit, tag, and release | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| DATE=$(TZ="Europe/Amsterdam" date "+%d-%m-%Y") | |
| NORMAL=$(wc -l < disposable_email/domains.txt) | |
| STRICT=$(wc -l < disposable_email/domains_strict.txt) | |
| # Determine next patch version | |
| LATEST_TAG=$(git tag --sort=-v:refname | head -1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| NEXT_TAG="0.0.1" | |
| else | |
| MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1) | |
| MINOR=$(echo "$LATEST_TAG" | cut -d. -f2) | |
| PATCH=$(echo "$LATEST_TAG" | cut -d. -f3) | |
| NEXT_TAG="${MAJOR}.${MINOR}.$((PATCH + 1))" | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add disposable_email/domains.txt disposable_email/domains_strict.txt | |
| git commit -m "chore: update domain list ${DATE}" | |
| git tag "$NEXT_TAG" | |
| git push origin main --tags | |
| - name: Create GitHub release | |
| if: steps.changes.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| NEXT_TAG=$(git tag --sort=-v:refname | head -1) | |
| NORMAL=$(wc -l < disposable_email/domains.txt) | |
| STRICT=$(wc -l < disposable_email/domains_strict.txt) | |
| gh release create "$NEXT_TAG" \ | |
| --title "$NEXT_TAG" \ | |
| --notes "Automated domain list update. | |
| | List | Domains | | |
| |------|---------| | |
| | \`domains.txt\` | ${NORMAL} | | |
| | \`domains_strict.txt\` | ${STRICT} |" | |
| - name: Build package | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| pip install build | |
| python -m build | |
| - name: Publish to PyPI | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: pypa/gh-action-pypi-publish@release/v1 |