Weird ass bug (#75) #112
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 to GitHub Pages | |
| on: | |
| push: | |
| branches: ['main', 'dev'] | |
| workflow_dispatch: | |
| jobs: | |
| # Builds production site and creates 'build-prod' artifact | |
| build-prod: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build production site | |
| # Since we have a top-level domain, this is no longer necessary | |
| # If we ever need to return to gtmun.github.io/couchmun, | |
| # uncomment these two lines. | |
| # env: | |
| # BASE_PATH: '/${{ github.event.repository.name }}' | |
| run: pnpm run build | |
| - name: Upload production build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 'build-prod' | |
| path: 'build' | |
| # Checks that dev branch exists to build dev site from | |
| does-dev-exist: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| dev-exists: ${{ steps.check.outputs.dev-exists }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Check whether dev branch exists | |
| id: check | |
| run: | | |
| if git ls-remote --exit-code --heads origin dev; then | |
| echo "dev-exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "dev-exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Builds dev site and creates 'build-dev' artifact | |
| build-dev: | |
| needs: does-dev-exist | |
| if: ${{ needs.does-dev-exist.outputs.dev-exists == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: "dev" | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build dev site | |
| env: | |
| BASE_PATH: '/dev' | |
| run: pnpm run build | |
| - name: Upload production build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 'build-dev' | |
| path: 'build' | |
| # Combines artifacts into single GitHub Pages artifact (allowing dev page to be skipped if not present) | |
| upload-site: | |
| needs: [build-prod, build-dev] | |
| if: ${{ !cancelled() && needs.build-prod.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download production build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: 'build-prod' | |
| path: 'build' | |
| - name: Download dev build | |
| uses: actions/download-artifact@v4 | |
| id: dl-dev-build | |
| with: | |
| name: 'build-dev' | |
| path: 'build/dev' | |
| continue-on-error: true | |
| - name: Show warning | |
| if: ${{ steps.dl-dev-build.outcome == 'failure' }} | |
| run: echo ::warning "title:Dev build failure::Could not build dev branch. Dev site will not be deployed." | |
| - name: Upload artifacts | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'build' | |
| # Deploys GitHub artifact | |
| deploy: | |
| needs: upload-site | |
| if: ${{ !cancelled() && needs.upload-site.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |