Skip to content

Commit 719f398

Browse files
committed
github pages deploy workflow
1 parent 575232a commit 719f398

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

.github/workflows/deploy.docs.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Deploy Documentation Site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- documentation
7+
8+
paths:
9+
- "docs/website-src/**"
10+
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
#- name: LikeC4 code generation
30+
# uses: likec4/actions@v1
31+
# with:
32+
# codegen: react
33+
# path: website/likec4_src
34+
# output: website/likec4_react/likec4.generated.js
35+
36+
#- name: LikeC4 PNG export
37+
# uses: likec4/actions@v1
38+
# with:
39+
# export: png
40+
# path: website/likec4_src
41+
# output: website/public/images/likec4
42+
43+
- name: Detect package manager
44+
id: detect-package-manager
45+
run: |
46+
if [ -f "docs/website-src/yarn.lock" ]; then
47+
echo "manager=yarn" >> $GITHUB_OUTPUT
48+
echo "command=install" >> $GITHUB_OUTPUT
49+
echo "runner=yarn" >> $GITHUB_OUTPUT
50+
exit 0
51+
elif [ -f "docs/website-src/package.json" ]; then
52+
echo "manager=npm" >> $GITHUB_OUTPUT
53+
echo "command=ci" >> $GITHUB_OUTPUT
54+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
55+
exit 0
56+
else
57+
echo "Unable to determine package manager"
58+
exit 1
59+
fi
60+
61+
- name: Setup Node
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: "20"
65+
66+
- name: Setup Pages
67+
uses: actions/configure-pages@v5
68+
69+
- name: Restore cache
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
.next/cache
74+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
75+
restore-keys: |
76+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
77+
78+
- name: Install dependencies
79+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
80+
working-directory: website
81+
82+
- name: Build with Next.js
83+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
84+
working-directory: website
85+
86+
- name: Copy built files to docs
87+
run: |
88+
rm -rf docs/website/*
89+
cp -r docs/website-src/out docs/website
90+
91+
- name: Upload artifact
92+
uses: actions/upload-pages-artifact@v3
93+
with:
94+
path: docs/website
95+
deploy:
96+
environment:
97+
name: github-pages
98+
url: ${{ steps.deployment.outputs.page_url }}
99+
runs-on: ubuntu-latest
100+
needs: build
101+
steps:
102+
- name: Deploy to GitHub Pages
103+
id: deployment
104+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)