Skip to content

Commit 380e4d0

Browse files
authored
format workflow
1 parent 056e379 commit 380e4d0

File tree

1 file changed

+70
-71
lines changed

1 file changed

+70
-71
lines changed

.github/workflows/deploy.yml

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,83 @@
22
#
33
# To get started with Next.js see: https://nextjs.org/docs/getting-started
44
#
5-
name: Deploy Next.js site to Pages
5+
name: GitHub Pages
66

77
on:
8-
# Runs on pushes targeting the default branch
9-
push:
10-
branches: ["main"]
8+
push:
9+
branches: ["main"]
1110

12-
# Allows you to run this workflow manually from the Actions tab
13-
workflow_dispatch:
11+
workflow_dispatch:
1412

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1613
permissions:
17-
contents: read
18-
pages: write
19-
id-token: write
14+
contents: read
15+
pages: write
16+
id-token: write
2017

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.
2318
concurrency:
24-
group: "pages"
25-
cancel-in-progress: false
19+
group: "pages"
20+
cancel-in-progress: false
2621

2722
jobs:
28-
# Build job
29-
build:
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v4
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
52-
uses: actions/setup-node@v4
53-
with:
54-
node-version: "20"
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
56-
- name: Restore cache
57-
uses: actions/cache@v4
58-
with:
59-
path: |
60-
.next/cache
61-
# Generate a new cache whenever packages or source files change.
62-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
63-
# If source files changed but packages didn't, rebuild from a prior cache.
64-
restore-keys: |
65-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
66-
- name: Install dependencies
67-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
68-
- name: Build with Next.js
69-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
70-
- name: Upload artifact
71-
uses: actions/upload-pages-artifact@v3
72-
with:
73-
path: ./out
23+
build:
24+
name: Build
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Detect package manager
31+
id: detect-package-manager
32+
run: |
33+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
34+
echo "manager=yarn" >> $GITHUB_OUTPUT
35+
echo "command=install" >> $GITHUB_OUTPUT
36+
echo "runner=yarn" >> $GITHUB_OUTPUT
37+
exit 0
38+
elif [ -f "${{ github.workspace }}/package.json" ]; then
39+
echo "manager=npm" >> $GITHUB_OUTPUT
40+
echo "command=ci" >> $GITHUB_OUTPUT
41+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
42+
exit 0
43+
else
44+
echo "Unable to determine package manager"
45+
exit 1
46+
fi
7447
75-
# Deployment job
76-
deploy:
77-
environment:
78-
name: github-pages
79-
url: ${{ steps.deployment.outputs.page_url }}
80-
runs-on: ubuntu-latest
81-
needs: build
82-
steps:
83-
- name: Deploy to GitHub Pages
84-
id: deployment
85-
uses: actions/deploy-pages@v4
48+
- name: Setup Node
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
cache: ${{ steps.detect-package-manager.outputs.manager }}
53+
54+
- name: Restore cache
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
.next/cache
59+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
60+
restore-keys: |
61+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
62+
63+
- name: Install dependencies
64+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
65+
66+
- name: Build with Next.js
67+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
68+
69+
- name: Upload artifact
70+
uses: actions/upload-pages-artifact@v3
71+
with:
72+
path: ./out
73+
74+
deploy:
75+
name: Deploy
76+
environment:
77+
name: github-pages
78+
url: ${{ steps.deployment.outputs.page_url }}
79+
runs-on: ubuntu-latest
80+
needs: build
81+
steps:
82+
- name: Deploy to GitHub Pages
83+
id: deployment
84+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)