Skip to content

Commit

Permalink
Add workflow files for managing previews and deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
Nateowami committed Oct 11, 2024
1 parent 8100929 commit 789ab19
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 11 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/approve-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Approve preview
on: workflow_dispatch

jobs:
deploy-preview:
name: Push preview to master
runs-on: ubuntu-latest
environment: deploy

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: preview

- name: Push to master
run: git push origin preview:master
23 changes: 23 additions & 0 deletions .github/workflows/deploy-live.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to live
on:
push:
branches:
- master

jobs:
deploy-live:
name: Deploy to live
runs-on: ubuntu-latest
environment: deploy

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build the site
run: ./build.sh

- name: Deploy to Netlify
run: ./deploy.sh --live
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
name: Update and Preview
on: workflow_dispatch
name: Deploy preview branch
on:
push:
branches:
- preview

jobs:
deploy-preview:
name: Deploy Preview
name: Deploy preview branch
runs-on: ubuntu-latest
environment: deploy

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Pull documents from Notion
run: ./pull_docs.sh --skip-pulling-from-s3
env:
SF_HELP_NOTION_TOKEN: ${{ secrets.SF_HELP_NOTION_TOKEN }}
SF_HELP_NOTION_ROOT_PAGE_ID: ${{ secrets.SF_HELP_NOTION_ROOT_PAGE_ID }}

- name: Build the site
run: ./build.sh

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/update-preview-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Update preview branch
on: workflow_dispatch

jobs:
deploy-preview:
name: Update preview branch
runs-on: ubuntu-latest
environment: deploy

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Pull documents from Notion
run: ./pull_docs.sh --skip-pulling-from-s3
env:
SF_HELP_NOTION_TOKEN: ${{ secrets.SF_HELP_NOTION_TOKEN }}
SF_HELP_NOTION_ROOT_PAGE_ID: ${{ secrets.SF_HELP_NOTION_ROOT_PAGE_ID }}

- name: Commit and push changes to preview branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update files from Notion"
git push -f origin HEAD:preview
4 changes: 3 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set -euxo pipefail
# NETLIFY_AUTH_TOKEN must be set in the environment
export NETLIFY_SITE_ID=aba3890d-2b7b-4144-883f-7c600965db82

if [ "$#" -eq 1 ] && [ "$1" == "--github-action-preview-subdomain" ]; then
if (( "$#" == 1 )) && [[ "$1" == "--github-action-preview-subdomain" ]]; then
npx netlify deploy --dir build --alias github-action-preview
elif (( "$#" == 1 )) && [[ "$1" == "--prod" ]]; then
npx netlify deploy --dir build --prod
else
npx netlify deploy --dir build
fi
2 changes: 1 addition & 1 deletion pull_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sed -i s/:::📝/:::note/g docs/*.md
# Add a div around the ReactPlayer component to make it responsive
sed -i -e '/<ReactPlayer/ s/^/<div class="player-wrapper">/' -e '/<ReactPlayer/ s/$/<\/div>/' docs/*.md

if [ "$#" -ge 1 ] && [ "$1" == "--skip-pulling-from-s3" ]; then
if (( "$#" == 1 )) && [[ "$1" == "--skip-pulling-from-s3" ]]; then
echo "Skipping pulling from S3."
else
mkdir -p s3
Expand Down

0 comments on commit 789ab19

Please sign in to comment.