Skip to content

Commit 8fa2e38

Browse files
committed
add pages build
1 parent 6cf7c3c commit 8fa2e38

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

.github/workflows/build-pages.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build frontend site and deploy to GitHub Pages
2+
3+
on:
4+
push: # Runs on pushes targeting the default branch
5+
branches: ['main']
6+
pull_request: # Runs on pull requests that targeting the default branch
7+
branches: ['main']
8+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
9+
10+
permissions: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: 'pages'
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
repository: ${{ vars.SRC_GITHUB_REPO }}
28+
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
29+
lfs: true
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: 10
33+
- id: detect-package-manager
34+
run: |
35+
set -ex && pwd && ls -alh
36+
if [ -f "${{ github.workspace }}/package-lock.json" ]; then
37+
echo "manager=npm" >> $GITHUB_OUTPUT && echo "command=install" >> $GITHUB_OUTPUT
38+
exit 0
39+
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
40+
echo "manager=pnpm" >> $GITHUB_OUTPUT && echo "command=install" >> $GITHUB_OUTPUT
41+
exit 0
42+
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
43+
echo "manager=yarn" >> $GITHUB_OUTPUT && echo "command=install" >> $GITHUB_OUTPUT
44+
exit 0
45+
else
46+
echo "Unable to determine package manager"
47+
exit 1
48+
fi
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: '20'
52+
cache: ${{ steps.detect-package-manager.outputs.manager }}
53+
- uses: actions/configure-pages@v5
54+
with:
55+
# Automatically inject basePath in your Next.js configuration file and disable
56+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
57+
# You may remove this line if you want to manage the configuration yourself.
58+
static_site_generator: next
59+
- uses: actions/cache@v4
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 FED
71+
run: ${{ steps.detect-package-manager.outputs.manager }} run build
72+
- name: Create CNAME file
73+
run: |
74+
echo "Generate CNAME file"
75+
echo ${{ vars.CNAME }} > ./out/CNAME
76+
- name: Upload artifact
77+
uses: actions/upload-pages-artifact@v3
78+
with:
79+
path: ./out
80+
81+
deploy: # Deployment job
82+
environment:
83+
name: github-pages
84+
url: ${{ steps.deployment.outputs.page_url }}
85+
runs-on: ubuntu-latest
86+
needs: build
87+
steps:
88+
- id: deployment
89+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)