|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths-ignore: |
| 5 | + - '.github/workflows/tag.yml' |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + repo: |
| 9 | + description: 'repo name' |
| 10 | + required: false |
| 11 | + schedule: |
| 12 | + - cron: "0 0 * * *" |
| 13 | + |
| 14 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + pages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +run-name: Build ${{ github.event.inputs.repo }} |
| 21 | + |
| 22 | +jobs: |
| 23 | + deploy: |
| 24 | + concurrency: |
| 25 | + group: ${{ github.sha }} |
| 26 | + environment: |
| 27 | + name: github-pages |
| 28 | + url: ${{ steps.deployment.outputs.page_url }} |
| 29 | + name: Build Website |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 1 |
| 36 | + |
| 37 | + - name: Setup Bun |
| 38 | + uses: oven-sh/setup-bun@v2 |
| 39 | + with: |
| 40 | + bun-version: latest |
| 41 | + |
| 42 | + - name: Clean cache (full rebuild) |
| 43 | + if: ${{ !github.event.inputs.repo }} |
| 44 | + run: | |
| 45 | + rm -rf .cache |
| 46 | + rm -rf dist |
| 47 | + echo "Cleaned cache for full rebuild" |
| 48 | +
|
| 49 | + - name: Restore .cache directory (incremental) |
| 50 | + if: ${{ github.event.inputs.repo }} |
| 51 | + uses: actions/cache/restore@v4 |
| 52 | + with: |
| 53 | + path: .cache |
| 54 | + key: ${{ runner.os }}-astro-cache-${{ github.run_id }} |
| 55 | + restore-keys: ${{ runner.os }}-astro-cache- |
| 56 | + |
| 57 | + - name: Restore dist directory (incremental) |
| 58 | + if: ${{ github.event.inputs.repo }} |
| 59 | + uses: actions/cache/restore@v4 |
| 60 | + with: |
| 61 | + path: dist |
| 62 | + key: ${{ runner.os }}-astro-dist-${{ github.run_id }} |
| 63 | + restore-keys: ${{ runner.os }}-astro-dist- |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + run: bun install --frozen-lockfile |
| 67 | + |
| 68 | + - name: Fetch module data |
| 69 | + run: bun run scripts/fetch-data.ts |
| 70 | + env: |
| 71 | + GRAPHQL_TOKEN: ${{ secrets.GRAPHQL_TOKEN }} |
| 72 | + REPO: ${{ github.event.inputs.repo }} |
| 73 | + |
| 74 | + - name: Build |
| 75 | + run: bun run build |
| 76 | + |
| 77 | + - name: Save .cache directory |
| 78 | + if: ${{ github.event.inputs.repo }} |
| 79 | + uses: actions/cache/save@v4 |
| 80 | + with: |
| 81 | + path: .cache |
| 82 | + key: ${{ runner.os }}-astro-cache-${{ github.run_id }} |
| 83 | + |
| 84 | + - name: Save dist directory |
| 85 | + if: ${{ github.event.inputs.repo }} |
| 86 | + uses: actions/cache/save@v4 |
| 87 | + with: |
| 88 | + path: dist |
| 89 | + key: ${{ runner.os }}-astro-dist-${{ github.run_id }} |
| 90 | + |
| 91 | + - name: Upload artifact |
| 92 | + uses: actions/upload-pages-artifact@v3 |
| 93 | + with: |
| 94 | + path: 'dist' |
| 95 | + |
| 96 | + - name: Deploy to GitHub Pages |
| 97 | + id: deployment |
| 98 | + uses: actions/deploy-pages@v4 |
0 commit comments