Skip to content

Commit ec9bdf9

Browse files
committed
GitHub workflows: Extract 'build-artifacts' into action and add workflows for Netlify deployments
1 parent 7b7f0bf commit ec9bdf9

File tree

4 files changed

+186
-92
lines changed

4 files changed

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

.github/workflows/draft-deploy.yml

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

.github/workflows/test-deploy.yml

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

.github/workflows/update.yml

Lines changed: 6 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -29,106 +29,20 @@ jobs:
2929
update:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v4
32+
- name: Checkout
33+
uses: actions/checkout@v4
3334

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
51-
52-
- uses: actions/cache@v4
53-
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
35+
- name: Build Artifacts
36+
uses: ./.github/actions/build-artifacts
12537

12638
- name: Setup Pages
12739
uses: actions/configure-pages@v5
40+
12841
- name: Upload GitHub Pages artifact
12942
uses: actions/upload-pages-artifact@v3.0.1
13043
with:
13144
path: build
45+
13246
- name: Deploy to GitHub Pages
13347
id: deployment
13448
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)