|
1 |
| -# Sample workflow for building and deploying a Nuxt site to GitHub Pages |
2 |
| -# |
3 |
| -# To get started with Nuxt see: https://nuxtjs.org/docs/get-started/installation |
4 |
| -# |
5 |
| -name: Deploy Nuxt site to Pages |
6 |
| - |
| 1 | +# https://github.com/actions/deploy-pages#usage |
| 2 | +name: Deploy to GitHub Pages |
7 | 3 | on:
|
8 |
| - # Runs on pushes targeting the default branch |
9 |
| - push: |
10 |
| - branches: ["main"] |
11 |
| - |
12 |
| - # Allows you to run this workflow manually from the Actions tab |
13 | 4 | workflow_dispatch:
|
14 |
| - |
15 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 |
| -permissions: |
17 |
| - contents: read |
18 |
| - pages: write |
19 |
| - id-token: write |
20 |
| - |
21 |
| -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
22 |
| -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
23 |
| -concurrency: |
24 |
| - group: "pages" |
25 |
| - cancel-in-progress: false |
26 |
| - |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - prod |
27 | 8 | jobs:
|
28 |
| - # Build job |
29 | 9 | build:
|
30 | 10 | runs-on: ubuntu-latest
|
31 | 11 | steps:
|
32 |
| - - name: Checkout |
33 |
| - uses: actions/checkout@v4 |
34 |
| - - name: Detect package manager |
35 |
| - id: detect-package-manager |
36 |
| - run: | |
37 |
| - if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
38 |
| - echo "manager=yarn" >> $GITHUB_OUTPUT |
39 |
| - echo "command=install" >> $GITHUB_OUTPUT |
40 |
| - exit 0 |
41 |
| - elif [ -f "${{ github.workspace }}/package.json" ]; then |
42 |
| - echo "manager=npm" >> $GITHUB_OUTPUT |
43 |
| - echo "command=ci" >> $GITHUB_OUTPUT |
44 |
| - exit 0 |
45 |
| - else |
46 |
| - echo "Unable to determine package manager" |
47 |
| - exit 1 |
48 |
| - fi |
49 |
| - - name: Setup Node |
50 |
| - uses: actions/setup-node@v4 |
| 12 | + - uses: actions/checkout@v3 |
| 13 | + - run: corepack enable |
| 14 | + - uses: actions/setup-node@v3 |
51 | 15 | with:
|
52 | 16 | node-version: "20"
|
53 |
| - cache: ${{ steps.detect-package-manager.outputs.manager }} |
54 |
| - - name: Setup Pages |
55 |
| - uses: actions/configure-pages@v5 |
56 |
| - with: |
57 |
| - # Automatically inject router.base in your Nuxt configuration file and set |
58 |
| - # target to static (https://nuxtjs.org/docs/configuration-glossary/configuration-target/). |
59 |
| - # |
60 |
| - # You may remove this line if you want to manage the configuration yourself. |
61 |
| - static_site_generator: nuxt |
62 |
| - - name: Restore cache |
63 |
| - uses: actions/cache@v4 |
64 |
| - with: |
65 |
| - path: | |
66 |
| - dist |
67 |
| - .nuxt |
68 |
| - key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} |
69 |
| - restore-keys: | |
70 |
| - ${{ runner.os }}-nuxt-build- |
71 |
| - - name: Install dependencies |
72 |
| - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
73 |
| - - name: Static HTML export with Nuxt |
74 |
| - run: ${{ steps.detect-package-manager.outputs.manager }} run generate |
| 17 | + # Pick your own package manager and build script |
| 18 | + - run: npm install |
| 19 | + - run: npx nuxt build --preset github_pages |
| 20 | + env: |
| 21 | + NUXT_APP_BASE_URL: ${{ vars.NUXT_APP_BASE_URL }} |
75 | 22 | - name: Upload artifact
|
76 | 23 | uses: actions/upload-pages-artifact@v3
|
77 | 24 | with:
|
78 |
| - path: ./dist |
79 |
| - |
| 25 | + path: ./.output/public |
80 | 26 | # Deployment job
|
81 | 27 | deploy:
|
| 28 | + # Add a dependency to the build job |
| 29 | + needs: build |
| 30 | + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment |
| 31 | + permissions: |
| 32 | + pages: write # to deploy to Pages |
| 33 | + id-token: write # to verify the deployment originates from an appropriate source |
| 34 | + # Deploy to the github_pages environment |
82 | 35 | environment:
|
83 |
| - name: github-pages |
| 36 | + name: github_pages |
84 | 37 | url: ${{ steps.deployment.outputs.page_url }}
|
| 38 | + # Specify runner + deployment step |
85 | 39 | runs-on: ubuntu-latest
|
86 |
| - needs: build |
87 | 40 | steps:
|
88 | 41 | - name: Deploy to GitHub Pages
|
89 | 42 | id: deployment
|
|
0 commit comments