Skip to content

Commit df7d164

Browse files
author
Luke Bowerman
authored
chore: Auto-deploy documentation web site
Configure Gatsby to support deploying to sub-directory - AppLogo, Navigation and PropExamples need to properly construct URLs - Use Gatsby Link for embedded page link Configure deploy to place build artifacts in subfolder `/v${VERSION}` Configure release deploy to sym-link version to /latest Configure index to redirect to /latest Put workflow steps in place to deploy canary and release versions of documentation site
1 parent 91c36a7 commit df7d164

File tree

20 files changed

+145
-146
lines changed

20 files changed

+145
-146
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ updates:
1010
reviewers:
1111
- lukelooker
1212
versioning-strategy: increase
13+
- package-ecosystem: github-actions
14+
directory: "/"
15+
schedule:
16+
interval: weekly

.github/workflows/canary-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- '**/package*.json'
1414

1515
jobs:
16-
release-canary:
16+
canary-release:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Clone repository
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Web Site (canary)
2+
3+
# This workflow creates or updates (if already exists) a pull request with new
4+
# version bump on every commit to main.
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- 'packages/**/*.ts'
12+
- 'packages/**/*.tsx'
13+
- 'www/src/**/'
14+
15+
jobs:
16+
canary-website:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Clone repository
20+
uses: actions/checkout@v2
21+
with:
22+
persist-credentials: false
23+
ref: main
24+
fetch-depth: 0
25+
26+
- name: Install dependencies
27+
run: |
28+
yarn install
29+
30+
- name: Build web site
31+
run: |
32+
yarn website-canary
33+
34+
- name: Deploy 🚀
35+
uses: JamesIves/[email protected]
36+
with:
37+
BRANCH: docs # The branch the action should deploy to.
38+
CLEAN: false # Don't remove deleted files from the deploy branch
39+
FOLDER: docs # The folder the action should deploy.
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
# SINGLE_COMMIT: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release web site
2+
3+
# This workflow does the following if repo does not have git tag that was updated in lerna.json
4+
# - creates release git tag
5+
# - publishes packages to NPM with latest tag
6+
#
7+
# This workflow is expected to run after merge of release pull requested created by release-pull-request workflow.
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- 'lerna.json'
15+
16+
jobs:
17+
release-website:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Clone repository
21+
uses: actions/checkout@v2
22+
with:
23+
persist-credentials: false
24+
ref: main
25+
fetch-depth: 0
26+
27+
- name: Install dependencies
28+
run: |
29+
yarn install
30+
31+
- name: Read version created by Lerna
32+
id: lerna_version
33+
run: |
34+
echo "::set-output name=version::v$(sed -nE 's/^\s*\"version\": \"(.*?)\",$/\1/p' lerna.json)"
35+
36+
- name: Build web site
37+
run: |
38+
yarn website-latest
39+
40+
- name: Deploy 🚀
41+
uses: JamesIves/[email protected]
42+
with:
43+
BRANCH: docs # The branch the action should deploy to.
44+
CLEAN: false # Automatically remove deleted files from the deploy branch
45+
FOLDER: docs # The folder the action should deploy.
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
# SINGLE_COMMIT: true

.github/workflows/release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ jobs:
2222
with:
2323
ref: main
2424
fetch-depth: 0
25+
2526
- name: Fetch all tags
2627
run: |
2728
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
29+
2830
- name: Install dependencies
2931
run: |
3032
yarn install
31-
- name: Read version created by Lerna.js
33+
34+
- name: Read version created by Lerna
3235
id: lerna_version
3336
run: |
34-
echo "::set-output name=version::v$(npm run version --silent)"
37+
echo "::set-output name=version::v$(sed -nE 's/^\s*\"version\": \"(.*?)\",$/\1/p' lerna.json)"
38+
3539
- name: Check if release tag is already created
3640
id: vars
3741
run: |
@@ -42,9 +46,11 @@ jobs:
4246
echo "New release already created, exiting."
4347
exit 1
4448
fi
49+
4550
- name: Build packages
4651
run: |
4752
yarn build
53+
4854
- name: Create release
4955
id: create_release
5056
uses: actions/create-release@v1
@@ -55,6 +61,7 @@ jobs:
5561
See CHANGELOG file to see what's changed in new release.
5662
env:
5763
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
5865
- name: Publish to NPM registry
5966
run: npx lerna publish from-package --yes
6067
env:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ node_modules
1414
.eslintcache
1515

1616
# code-gen
17-
docs/static
17+
docs/v*/**
1818
packages/icons/src/generated
1919
playground/dist
2020
storybook-static

config/deploy.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

config/website-canary.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
config/website.sh canary

config/website-latest.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
PACKAGE_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' lerna.json)
3+
config/website.sh $PACKAGE_VERSION
4+
5+
# Copy to `/latest` for default usage
6+
rm -rf docs/latest
7+
cp -r docs/$PACKAGE_VERSION docs/latest

config/website.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
VERSION=$1
4+
5+
# clean-up previous build if exists
6+
rm -rf docs/$VERSION
7+
8+
# Build Gatsby, then move contents to public folder for publishing
9+
sed -i -e "s/VERSION/$VERSION/g" www/gatsby-config.js
10+
yarn workspace www build
11+
mv www/public docs/$VERSION
12+
13+
# Build Storybooks
14+
yarn workspace storybook build
15+
mv storybook/storybook-static docs/$VERSION/storybook

0 commit comments

Comments
 (0)