Build Feed #297
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 Feed | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # every hour | |
| workflow_dispatch: # manual trigger from GitHub UI | |
| push: | |
| paths: | |
| - 'data/feeds.json' # re-run whenever feeds list changes | |
| permissions: | |
| contents: write # needed to commit cache + push to Pages | |
| jobs: | |
| # ── Unit + integration tests ───────────────────────────────────────────────── | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run unit & integration tests | |
| run: npm test | |
| # ── Main build + deploy ─────────────────────────────────────────────────────── | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test # ← blocks deploy if tests fail | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| # ── Cache Ollama model ──────────────────────────────────────────────── | |
| - name: Cache Ollama model | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ollama/models | |
| key: ollama-llama3.2-1b | |
| restore-keys: | | |
| ollama-llama3.2-1b | |
| # ── Install & start Ollama ─────────────────────────────────────────── | |
| - name: Install Ollama | |
| run: curl -fsSL https://ollama.com/install.sh | sh | |
| - name: Start Ollama service | |
| run: ollama serve & | |
| # Give it a moment to bind the port | |
| - name: Wait for Ollama to be ready | |
| run: | | |
| for i in $(seq 1 15); do | |
| curl -sf http://127.0.0.1:11434/api/tags && break | |
| echo "Waiting for Ollama... ($i)" | |
| sleep 2 | |
| done | |
| - name: Pull model | |
| run: ollama pull ${{ vars.OLLAMA_MODEL || 'llama3.2:1b' }} | |
| # ── Build feed with LLM classification ────────────────────────────── | |
| - name: Build feed data | |
| env: | |
| USE_LLM: '1' | |
| OLLAMA_MODEL: ${{ vars.OLLAMA_MODEL || 'llama3.2:1b' }} | |
| run: node scripts/generate-version.mjs && node scripts/build-feed.mjs | |
| - name: Generate sitemap & SEO content | |
| run: node scripts/generate-sitemap.mjs && node scripts/generate-seo-content.mjs | |
| # ── Commit updated AI cache back to repo ──────────────────────────── | |
| - name: Commit AI classification cache | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git diff --cached --quiet && echo "Nothing to commit" && exit 0 | |
| git commit -m "chore: refresh feed + update AI classification cache [skip ci]" | |
| git pull --rebase --autostash origin main | |
| git push | |
| # ── Build & deploy to GitHub Pages ────────────────────────────────── | |
| - name: Build Vite app | |
| run: npm run build:app | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| cname: geekspulse.dev | |
| # ── E2E smoke tests ─────────────────────────────────────────────────────────── | |
| e2e: | |
| runs-on: ubuntu-latest | |
| needs: build # runs after the app is built + deployed | |
| # Only run E2E on the main branch to avoid hammering preview deploys | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| run: npx playwright install chromium --with-deps | |
| # Wait for GitHub Pages to propagate before running E2E tests | |
| - name: Wait for Pages deployment to propagate | |
| run: sleep 30 | |
| - name: Run E2E smoke tests | |
| run: npm run test:e2e | |
| env: | |
| CI: true | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 7 |