Skip to content

Commit 2627c25

Browse files
authored
Configure Netlify deployments (#252)
2 parents f23e64b + 7a0e57f commit 2627c25

File tree

4 files changed

+185
-98
lines changed

4 files changed

+185
-98
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build Docs Artifacts
2+
description: Builds the documentation artifacts including Docusaus, Sample App and Designer
3+
inputs:
4+
PERSONAL_ACCESS_TOKEN:
5+
description: 'A Github PAT'
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
# https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: 20
14+
registry-url: "https://registry.npmjs.org"
15+
scope: "@public-ui"
16+
17+
- uses: pnpm/action-setup@v4
18+
id: pnpm-install
19+
with:
20+
version: 9
21+
run_install: false
22+
23+
- name: Get pnpm store directory
24+
id: pnpm-cache
25+
shell: bash
26+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
27+
28+
- uses: actions/cache@v4
29+
with:
30+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
31+
key: ${{ runner.os }}-pnpm-store
32+
restore-keys: |
33+
${{ runner.os }}-pnpm-store
34+
35+
- name: Build Docs
36+
shell: bash
37+
run: |
38+
pnpm install --no-frozen-lockfile
39+
npm run build
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: 20
43+
registry-url: "https://npm.pkg.github.com"
44+
scope: "@public-ui"
45+
46+
- name: Download designer (v1)
47+
env:
48+
NODE_AUTH_TOKEN: ${{ inputs.PERSONAL_ACCESS_TOKEN }}
49+
shell: bash
50+
run: |
51+
rm -rf package *.tgz
52+
npm pack @public-ui/designer@^1
53+
tar -xzvf public-ui-designer-*.tgz
54+
55+
rm -rf build/v1/designer
56+
mkdir -p build/v1
57+
mv package/dist build/v1/designer
58+
59+
rm -rf package *.tgz
60+
61+
- name: Download sample react (v1)
62+
env:
63+
NODE_AUTH_TOKEN: ${{ inputs.PERSONAL_ACCESS_TOKEN }}
64+
shell: bash
65+
run: |
66+
rm -rf package *.tgz
67+
npm pack @public-ui/sample-react@^1
68+
tar -xzvf public-ui-sample-react-*.tgz
69+
70+
rm -rf build/v1/sample-react
71+
mkdir -p build/v1
72+
mv package/dist build/v1/sample-react
73+
74+
rm -rf package *.tgz
75+
76+
- name: Download designer (v2)
77+
env:
78+
NODE_AUTH_TOKEN: ${{ inputs.PERSONAL_ACCESS_TOKEN }}
79+
shell: bash
80+
run: |
81+
rm -rf package *.tgz
82+
npm pack @public-ui/designer@^2
83+
tar -xzvf public-ui-designer-*.tgz
84+
85+
rm -rf build/v2/designer
86+
mkdir -p build/v2
87+
mv package/dist build/v2/designer
88+
89+
rm -rf package *.tgz
90+
91+
- name: Download sample react (v2)
92+
env:
93+
NODE_AUTH_TOKEN: ${{ inputs.PERSONAL_ACCESS_TOKEN }}
94+
shell: bash
95+
run: |
96+
rm -rf package *.tgz
97+
npm pack @public-ui/sample-react@^2
98+
tar -xzvf public-ui-sample-react-*.tgz
99+
100+
rm -rf build/v2/sample-react
101+
mkdir -p build/v2
102+
mv package/dist build/v2/sample-react
103+
104+
rm -rf package *.tgz

.github/workflows/draft-deploy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Netlify Draft Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
build-and-deploy:
9+
if: ${{ github.event.pull_request.base.repo.clone_url == github.event.pull_request.head.repo.clone_url }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Build Artifacts
16+
uses: ./.github/actions/build-artifacts
17+
with:
18+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
19+
20+
- name: Netlify Deploy
21+
uses: netlify/actions/cli@master
22+
id: netlify
23+
env:
24+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
25+
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
26+
with:
27+
args: deploy --dir=build
28+
29+
- name: Find comment
30+
uses: peter-evans/find-comment@v3
31+
id: fc
32+
with:
33+
issue-number: ${{ github.event.pull_request.number }}
34+
comment-author: 'github-actions[bot]'
35+
body-includes: Netlify Draft Deployment
36+
37+
- name: Create or update comment
38+
uses: peter-evans/create-or-update-comment@v4
39+
with:
40+
comment-id: ${{ steps.fc.outputs.comment-id }}
41+
issue-number: ${{ github.event.pull_request.number }}
42+
body: |
43+
Netlify Draft Deployment
44+
URL: ${{ steps.netlify.outputs.NETLIFY_URL }}
45+
Logs: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}
46+
edit-mode: replace

.github/workflows/test-deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Netlify Test Deploy - Deploy main branch under fixed alias
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Build Artifacts
17+
uses: ./.github/actions/build-artifacts
18+
with:
19+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
20+
21+
- name: Netlify Deploy
22+
uses: netlify/actions/cli@master
23+
id: netlify
24+
env:
25+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
26+
NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }}
27+
with:
28+
args: deploy --dir=build --alias="$GITHUB_REF_NAME"

.github/workflows/update.yml

Lines changed: 7 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
name: Update GitHub page
22

3-
env:
4-
github-registry: https://npm.pkg.github.com
5-
github-token: ${{ secrets.GITHUB_TOKEN }}
6-
npmjs-registry: https://registry.npmjs.org
7-
scope: public-ui
8-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
9-
103
on:
114
push:
125
branches:
@@ -29,106 +22,22 @@ jobs:
2922
update:
3023
runs-on: ubuntu-latest
3124
steps:
32-
- uses: actions/checkout@v4
33-
34-
# https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
35-
- uses: actions/setup-node@v4
36-
with:
37-
node-version: 20
38-
registry-url: "${{env.npmjs-registry}}"
39-
scope: "@${{env.scope}}"
40-
41-
- uses: pnpm/action-setup@v4
42-
id: pnpm-install
43-
with:
44-
version: 9
45-
run_install: false
46-
47-
- name: Get pnpm store directory
48-
id: pnpm-cache
49-
shell: bash
50-
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
25+
- name: Checkout
26+
uses: actions/checkout@v4
5127

52-
- uses: actions/cache@v4
28+
- name: Build Artifacts
29+
uses: ./.github/actions/build-artifacts
5330
with:
54-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
55-
key: ${{ runner.os }}-pnpm-store
56-
restore-keys: |
57-
${{ runner.os }}-pnpm-store
58-
59-
- name: Build Docs
60-
run: |
61-
pnpm install --no-frozen-lockfile
62-
npm run build
63-
64-
- uses: actions/setup-node@v4
65-
with:
66-
node-version: 20
67-
registry-url: "${{env.github-registry}}"
68-
scope: "@${{env.scope}}"
69-
70-
- name: Download designer (v1)
71-
env:
72-
NODE_AUTH_TOKEN: ${{env.token}}
73-
run: |
74-
rm -rf package *.tgz
75-
npm pack @${{env.scope}}/designer@^1
76-
tar -xzvf public-ui-designer-*.tgz
77-
78-
rm -rf build/v1/designer
79-
mkdir -p build/v1
80-
mv package/dist build/v1/designer
81-
82-
rm -rf package *.tgz
83-
84-
- name: Download sample react (v1)
85-
env:
86-
NODE_AUTH_TOKEN: ${{env.token}}
87-
run: |
88-
rm -rf package *.tgz
89-
npm pack @${{env.scope}}/sample-react@^1
90-
tar -xzvf public-ui-sample-react-*.tgz
91-
92-
rm -rf build/v1/sample-react
93-
mkdir -p build/v1
94-
mv package/dist build/v1/sample-react
95-
96-
rm -rf package *.tgz
97-
98-
- name: Download designer (v2)
99-
env:
100-
NODE_AUTH_TOKEN: ${{env.token}}
101-
run: |
102-
rm -rf package *.tgz
103-
npm pack @${{env.scope}}/designer@^2
104-
tar -xzvf public-ui-designer-*.tgz
105-
106-
rm -rf build/v2/designer
107-
mkdir -p build/v2
108-
mv package/dist build/v2/designer
109-
110-
rm -rf package *.tgz
111-
112-
- name: Download sample react (v2)
113-
env:
114-
NODE_AUTH_TOKEN: ${{env.token}}
115-
run: |
116-
rm -rf package *.tgz
117-
npm pack @${{env.scope}}/sample-react@^2
118-
tar -xzvf public-ui-sample-react-*.tgz
119-
120-
rm -rf build/v2/sample-react
121-
mkdir -p build/v2
122-
mv package/dist build/v2/sample-react
123-
124-
rm -rf package *.tgz
31+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
12532

12633
- name: Setup Pages
12734
uses: actions/configure-pages@v5
35+
12836
- name: Upload GitHub Pages artifact
12937
uses: actions/upload-pages-artifact@v3.0.1
13038
with:
13139
path: build
40+
13241
- name: Deploy to GitHub Pages
13342
id: deployment
13443
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)