Fetch data & deploy to GitHub Pages #495
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: Fetch data & deploy to GitHub Pages | |
| # trigger | |
| on: | |
| push: | |
| branches: [main] | |
| schedule: | |
| - cron: '0 */6 * * *' # packages: refresh every 6 hours | |
| - cron: '0 3 * * 1' # people/PRs: refresh weekly (Mon 03:00 UTC) | |
| workflow_dispatch: # manual trigger from the Actions tab | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Fetch npm, pub.dev & GitHub data | |
| run: bun scripts/fetch-data.ts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Fetch OSS PR contributions (weekly cron / manual / push) | |
| if: github.event_name != 'schedule' || github.event.schedule == '0 3 * * 1' | |
| # Uses a PAT (OSS_VISUALIZER_TOKEN: read:org + public_repo, from a bamlab member) | |
| # because the default GITHUB_TOKEN only lists PUBLIC org members. The script | |
| # exits non-zero without overwriting prs.json if it sees fewer than 20 members. | |
| continue-on-error: true | |
| run: bun scripts/fetch-prs.ts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.OSS_VISUALIZER_TOKEN || secrets.GITHUB_TOKEN }} | |
| - name: Persist data snapshots | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add public/data.json public/prs.json 2>/dev/null || true | |
| git diff --staged --quiet || git commit -m "chore: update data snapshot [skip ci]" | |
| git push | |
| - name: Build | |
| run: bun run build | |
| env: | |
| VITE_BASE_URL: /${{ github.event.repository.name }}/ | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: dist | |
| - name: Deploy to GitHub Pages | |
| id: deploy | |
| uses: actions/deploy-pages@v4 |