Scan, Build & Deploy to GitHub Pages (Daily) #264
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: Scan, Build & Deploy to GitHub Pages (Daily) | |
| on: | |
| workflow_dispatch: # manual run | |
| push: | |
| branches: [ "main" ] # deploy on push to main | |
| schedule: | |
| - cron: "0 3 * * *" # daily at 03:00 UTC | |
| # Only one deploy per ref at a time | |
| concurrency: | |
| group: github-pages-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Required for Pages deployment + committing history | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| # metadata for footer | |
| GIT_COMMIT_SHA: ${{ github.sha }} | |
| REPO_URL: https://github.com/${{ github.repository }} | |
| AUTHOR_NAME: 'Sprudeel' | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || '' }} | |
| # scanner config | |
| DOMAINS_FILE: domains.txt | |
| OUTPUT_FILE: public/whois.json | |
| HISTORY_FILE: public/history.json | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: { fetch-depth: 1 } | |
| - name: Setup Node | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| # 1) Generate the JSON snapshot | |
| - name: Run scanner | |
| run: node scripts/scan-domains.mjs | |
| # 2) Commit history.json changes back to repo | |
| - name: Commit history changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add public/history.json | |
| git diff --staged --quiet || git commit -m "chore: update history.json [skip ci]" | |
| git push || echo "Nothing to push" | |
| # 3) Build a static site into .output/public | |
| - name: Generate static site | |
| run: npm run generate | |
| # 4) Upload Pages artifact | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: .output/public | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |