Skip to content

Commit 5cf488d

Browse files
Rename build step in deploy workflow
1 parent 09ff28a commit 5cf488d

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Workflow for building and deploying to GitHub Pages
2+
3+
name: Deploy site to Pages
4+
5+
on:
6+
# Runs on pushes targeting the default branch
7+
push:
8+
branches: ["main"]
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
19+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: false
24+
25+
jobs:
26+
# Build job
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
- name: Detect package manager
33+
id: detect-package-manager
34+
run: |
35+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
36+
echo "manager=yarn" >> $GITHUB_OUTPUT
37+
echo "command=install" >> $GITHUB_OUTPUT
38+
echo "runner=yarn" >> $GITHUB_OUTPUT
39+
exit 0
40+
elif [ -f "${{ github.workspace }}/package.json" ]; then
41+
echo "manager=npm" >> $GITHUB_OUTPUT
42+
echo "command=ci" >> $GITHUB_OUTPUT
43+
echo "runner=npx --no-install" >> $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
51+
with:
52+
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 basePath in your Next.js configuration file and disable
58+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
59+
#
60+
# You may remove this line if you want to manage the configuration yourself.
61+
static_site_generator: next
62+
- name: Restore cache
63+
uses: actions/cache@v4
64+
with:
65+
path: |
66+
.next/cache
67+
# Generate a new cache whenever packages or source files change.
68+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
69+
# If source files changed but packages didn't, rebuild from a prior cache.
70+
restore-keys: |
71+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
72+
- name: Install dependencies
73+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
74+
- name: Build
75+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
76+
- name: Upload artifact
77+
uses: actions/upload-pages-artifact@v3
78+
with:
79+
path: ./out
80+
81+
# Deployment job
82+
deploy:
83+
environment:
84+
name: github-pages
85+
url: ${{ steps.deployment.outputs.page_url }}
86+
runs-on: ubuntu-latest
87+
needs: build
88+
steps:
89+
- name: Deploy to GitHub Pages
90+
id: deployment
91+
uses: actions/deploy-pages@v5

0 commit comments

Comments
 (0)