Skip to content

Commit ba8a5f8

Browse files
authored
Merge pull request #10
fix: fix workflows
2 parents e8c9d06 + 078e0e2 commit ba8a5f8

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/nextjs.yml

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

0 commit comments

Comments
 (0)