Skip to content

Commit 9147c44

Browse files
committed
feat: update deploy script
1 parent 5e1f10a commit 9147c44

File tree

1 file changed

+28
-58
lines changed

1 file changed

+28
-58
lines changed

.github/workflows/deploy.yml

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,57 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2-
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
5-
name: Deploy Next.js site to Pages
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: CI Deploy
3+
#name: Deploy static content to Pages
64

75
on:
86
# Runs on pushes targeting the default branch
97
push:
10-
branches: ["master"]
8+
branches: ['main']
119

1210
# Allows you to run this workflow manually from the Actions tab
1311
workflow_dispatch:
1412

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
1614
permissions:
1715
contents: read
1816
pages: write
1917
id-token: write
2018

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.
19+
# Allow one concurrent deployment
2320
concurrency:
24-
group: "pages"
25-
cancel-in-progress: false
21+
group: 'pages'
22+
cancel-in-progress: true
2623

2724
jobs:
28-
# Build job
29-
build:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout
3333
uses: actions/checkout@v3
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-
echo "runner=yarn" >> $GITHUB_OUTPUT
41-
exit 0
42-
elif [ -f "${{ github.workspace }}/package.json" ]; then
43-
echo "manager=npm" >> $GITHUB_OUTPUT
44-
echo "command=ci" >> $GITHUB_OUTPUT
45-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
46-
exit 0
47-
else
48-
echo "Unable to determine package manager"
49-
exit 1
50-
fi
51-
- name: Setup Node
34+
35+
- name: Setup pnpm
36+
uses: pnpm/[email protected]
37+
with:
38+
version: 8.6.1
39+
- name: Set up Node
5240
uses: actions/setup-node@v3
5341
with:
54-
node-version: "lts/*"
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
42+
node-version: 18
43+
cache: 'pnpm'
44+
- name: Install dependencies
45+
run: pnpm install --no-frozen-lockfile
46+
- name: Build
47+
run: npm run build
5648
- name: Setup Pages
5749
uses: actions/configure-pages@v3
58-
- name: Restore cache
59-
uses: actions/cache@v3
60-
with:
61-
path: |
62-
.next/cache
63-
# Generate a new cache whenever packages or source files change.
64-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
65-
# If source files changed but packages didn't, rebuild from a prior cache.
66-
restore-keys: |
67-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
68-
- name: Install dependencies
69-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
70-
- name: Build with Next.js
71-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
7250
- name: Upload artifact
7351
uses: actions/upload-pages-artifact@v1
7452
with:
75-
path: ./out
76-
77-
# Deployment job
78-
deploy:
79-
environment:
80-
name: github-pages
81-
url: ${{ steps.deployment.outputs.page_url }}
82-
runs-on: ubuntu-latest
83-
needs: build
84-
steps:
53+
# Upload dist repository
54+
path: './dist'
8555
- name: Deploy to GitHub Pages
8656
id: deployment
87-
uses: actions/deploy-pages@v2
57+
uses: actions/deploy-pages@v1

0 commit comments

Comments
 (0)