Deploy GitHub Pages #10
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: Deploy GitHub Pages | |
| on: | |
| workflow_run: | |
| workflows: | |
| - CI | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| pull-requests: read | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build site | |
| if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out verified revision | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Set up GitHub Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Resolve build metadata | |
| env: | |
| BUILD_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| echo "VITE_BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_ENV" | |
| build_pr_url="$(gh api "repos/${GITHUB_REPOSITORY}/commits/${BUILD_SHA}/pulls" --jq '.[0].html_url // empty')" | |
| if [ -z "$build_pr_url" ]; then | |
| build_pr_url="https://github.com/${GITHUB_REPOSITORY}/pulls?q=is%3Apr+is%3Aclosed" | |
| fi | |
| echo "VITE_BUILD_PR_URL=${build_pr_url}" >> "$GITHUB_ENV" | |
| - name: Build site | |
| run: bun run build | |
| - name: Upload site artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: dist | |
| deploy: | |
| name: Deploy site | |
| 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@v5 |