|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: "pages" |
| 15 | + cancel-in-progress: false |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + - name: npm |
| 24 | + id: install-npm |
| 25 | + run: npm i |
| 26 | + - name: Detect package manager |
| 27 | + id: detect-package-manager |
| 28 | + run: | |
| 29 | + if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
| 30 | + echo "manager=yarn" >> $GITHUB_OUTPUT |
| 31 | + echo "command=install" >> $GITHUB_OUTPUT |
| 32 | + echo "runner=yarn" >> $GITHUB_OUTPUT |
| 33 | + exit 0 |
| 34 | + elif [ -f "${{ github.workspace }}/package.json" ]; then |
| 35 | + echo "manager=npm" >> $GITHUB_OUTPUT |
| 36 | + echo "command=ci" >> $GITHUB_OUTPUT |
| 37 | + echo "runner=npx --no-install" >> $GITHUB_OUTPUT |
| 38 | + exit 0 |
| 39 | + else |
| 40 | + echo "Unable to determine package manager" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + - name: Setup Node |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: "20" |
| 47 | + cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 48 | + - name: Setup Pages |
| 49 | + uses: actions/configure-pages@v5 |
| 50 | + with: |
| 51 | + static_site_generator: next |
| 52 | + - name: Restore cache |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: | |
| 56 | + .next/cache |
| 57 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- |
| 60 | + - name: Install dependencies |
| 61 | + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
| 62 | + - name: Build with Next.js |
| 63 | + run: ${{ steps.detect-package-manager.outputs.runner }} next build |
| 64 | + - name: Override with _just |
| 65 | + uses: js-just/latest@main |
| 66 | + - name: Move id to deploy |
| 67 | + run: mv id deploy/id |
| 68 | + - name: Upload artifact |
| 69 | + uses: actions/upload-pages-artifact@v3 |
| 70 | + with: |
| 71 | + path: deploy |
| 72 | + |
| 73 | + deploy: |
| 74 | + environment: |
| 75 | + name: github-pages |
| 76 | + url: ${{ steps.deployment.outputs.page_url }} |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: build |
| 79 | + steps: |
| 80 | + - name: Deploy to GitHub Pages |
| 81 | + id: deployment |
| 82 | + uses: actions/deploy-pages@v4 |
0 commit comments