Skip to content

Commit 7a706a3

Browse files
authored
Update Nuxt GitHub workflow
1 parent 1215130 commit 7a706a3

File tree

1 file changed

+23
-73
lines changed

1 file changed

+23
-73
lines changed

.github/workflows/pages.yml

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,40 @@
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
72
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
133
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
267
jobs:
27-
# Build job
288
build:
299
runs-on: ubuntu-latest
3010
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
5614
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
7519
- name: Upload artifact
76-
uses: actions/upload-pages-artifact@v1
20+
uses: actions/upload-pages-artifact@v3
7721
with:
78-
path: ./dist
79-
22+
path: ./.output/public
8023
# Deployment job
8124
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
8232
environment:
83-
name: github-pages
33+
name: github_pages
8434
url: ${{ steps.deployment.outputs.page_url }}
35+
# Specify runner + deployment step
8536
runs-on: ubuntu-latest
86-
needs: build
8737
steps:
8838
- name: Deploy to GitHub Pages
8939
id: deployment
90-
uses: actions/deploy-pages@v1
40+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)