Skip to content

Commit 0c384eb

Browse files
committed
Add workflow files for managing previews and deploys
1 parent 8100929 commit 0c384eb

File tree

6 files changed

+87
-4
lines changed

6 files changed

+87
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy master to live
2+
on: workflow_dispatch
3+
4+
jobs:
5+
deploy-live:
6+
name: Deploy master to live
7+
runs-on: ubuntu-latest
8+
environment: deploy
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
with:
14+
ref: master
15+
16+
- name: Build the site
17+
run: ./build.sh
18+
19+
- name: Deploy to Netlify
20+
run: ./deploy.sh --live
21+
env:
22+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Push preview to master and deploy to live
2+
on: workflow_dispatch
3+
4+
jobs:
5+
deploy-preview:
6+
name: Push preview to master and deploy to live
7+
runs-on: ubuntu-latest
8+
environment: deploy
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
with:
14+
ref: preview
15+
16+
- name: Build the site
17+
run: ./build.sh
18+
19+
- name: Push preview to master
20+
run: git push origin preview:master
21+
22+
- name: Deploy to Netlify
23+
run: ./deploy.sh --live
24+
env:
25+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

.github/workflows/deploy-preview.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy preview branch
2+
on: workflow_dispatch
3+
4+
jobs:
5+
deploy-preview:
6+
name: Deploy preview branch
7+
runs-on: ubuntu-latest
8+
environment: deploy
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
with:
14+
ref: preview
15+
16+
- name: Build the site
17+
run: ./build.sh
18+
19+
- name: Deploy preview to Netlify
20+
run: ./deploy.sh --github-action-preview-subdomain
21+
env:
22+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

.github/workflows/update-and-preview.yml renamed to .github/workflows/fetch-and-deploy-preview.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Update and Preview
1+
name: Fetch docs and deploy preview branch
22
on: workflow_dispatch
33

44
jobs:
55
deploy-preview:
6-
name: Deploy Preview
6+
name: Fetch docs and deploy preview branch
77
runs-on: ubuntu-latest
88
environment: deploy
99

@@ -17,9 +17,21 @@ jobs:
1717
SF_HELP_NOTION_TOKEN: ${{ secrets.SF_HELP_NOTION_TOKEN }}
1818
SF_HELP_NOTION_ROOT_PAGE_ID: ${{ secrets.SF_HELP_NOTION_ROOT_PAGE_ID }}
1919

20+
- name: Commit changes
21+
run: |
22+
git config user.name "github-actions[bot]"
23+
git config user.email "github-actions[bot]@users.noreply.github.com"
24+
git add .
25+
git commit -m "Update files from Notion"
26+
2027
- name: Build the site
2128
run: ./build.sh
2229

30+
- name: Push changes to preview branch
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: git push -f origin HEAD:preview
34+
2335
- name: Deploy preview to Netlify
2436
run: ./deploy.sh --github-action-preview-subdomain
2537
env:

deploy.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ set -euxo pipefail
55
# NETLIFY_AUTH_TOKEN must be set in the environment
66
export NETLIFY_SITE_ID=aba3890d-2b7b-4144-883f-7c600965db82
77

8-
if [ "$#" -eq 1 ] && [ "$1" == "--github-action-preview-subdomain" ]; then
8+
if (( "$#" == 1 )) && [[ "$1" == "--github-action-preview-subdomain" ]]; then
99
npx netlify deploy --dir build --alias github-action-preview
10+
elif (( "$#" == 1 )) && [[ "$1" == "--prod" ]]; then
11+
npx netlify deploy --dir build --prod
1012
else
1113
npx netlify deploy --dir build
1214
fi

pull_docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sed -i s/:::📝/:::note/g docs/*.md
1111
# Add a div around the ReactPlayer component to make it responsive
1212
sed -i -e '/<ReactPlayer/ s/^/<div class="player-wrapper">/' -e '/<ReactPlayer/ s/$/<\/div>/' docs/*.md
1313

14-
if [ "$#" -ge 1 ] && [ "$1" == "--skip-pulling-from-s3" ]; then
14+
if (( "$#" == 1 )) && [[ "$1" == "--skip-pulling-from-s3" ]]; then
1515
echo "Skipping pulling from S3."
1616
else
1717
mkdir -p s3

0 commit comments

Comments
 (0)