|
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 | +name: Deploy to GitHub Pages |
7 | 2 | on: |
8 | | - # Runs on pushes targeting the default branch |
9 | | - push: |
10 | | - branches: ["master"] |
11 | | - |
12 | | - # Allows you to run this workflow manually from the Actions tab |
13 | 3 | 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 one concurrent deployment |
22 | | -concurrency: |
23 | | - group: "pages" |
24 | | - cancel-in-progress: true |
25 | | - |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
26 | 7 | jobs: |
27 | | - # Build job |
28 | 8 | build: |
29 | 9 | runs-on: ubuntu-latest |
30 | 10 | steps: |
31 | | - - name: Checkout |
32 | | - uses: actions/checkout@v3 |
33 | | - - name: Detect package manager |
34 | | - id: detect-package-manager |
35 | | - run: | |
36 | | - if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
37 | | - echo "::set-output name=manager::yarn" |
38 | | - echo "::set-output name=command::install" |
39 | | - exit 0 |
40 | | - elif [ -f "${{ github.workspace }}/package.json" ]; then |
41 | | - echo "::set-output name=manager::npm" |
42 | | - echo "::set-output name=command::ci" |
43 | | - exit 0 |
44 | | - else |
45 | | - echo "Unable to determine packager manager" |
46 | | - exit 1 |
47 | | - fi |
48 | | - - name: Setup Node |
49 | | - uses: actions/setup-node@v3 |
50 | | - with: |
51 | | - node-version: "16" |
52 | | - cache: ${{ steps.detect-package-manager.outputs.manager }} |
53 | | - - name: Setup Pages |
54 | | - id: pages |
55 | | - uses: actions/configure-pages@v1 |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - run: corepack enable |
| 13 | + - uses: actions/setup-node@v4 |
56 | 14 | 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@v3 |
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 |
| 15 | + node-version: "20" |
| 16 | + # Pick your own package manager and build script |
| 17 | + - run: npm install |
| 18 | + - run: npx nuxt build --preset github_pages |
75 | 19 | - name: Upload artifact |
76 | | - uses: actions/upload-pages-artifact@v1 |
| 20 | + uses: actions/upload-pages-artifact@v3 |
77 | 21 | with: |
78 | | - path: ./dist |
79 | | - |
| 22 | + path: ./.output/public |
80 | 23 | # Deployment job |
81 | 24 | deploy: |
| 25 | + # Add a dependency to the build job |
| 26 | + needs: build |
| 27 | + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment |
| 28 | + permissions: |
| 29 | + pages: write # to deploy to Pages |
| 30 | + id-token: write # to verify the deployment originates from an appropriate source |
| 31 | + # Deploy to the github_pages environment |
82 | 32 | environment: |
83 | | - name: github-pages |
| 33 | + name: github_pages |
84 | 34 | url: ${{ steps.deployment.outputs.page_url }} |
| 35 | + # Specify runner + deployment step |
85 | 36 | runs-on: ubuntu-latest |
86 | | - needs: build |
87 | 37 | steps: |
88 | 38 | - name: Deploy to GitHub Pages |
89 | 39 | id: deployment |
90 | | - uses: actions/deploy-pages@v1 |
| 40 | + uses: actions/deploy-pages@v4 |
0 commit comments