Skip to content

Commit

Permalink
Merge pull request #698 from GSA/pr-branches
Browse files Browse the repository at this point in the history
Add workflows to deploy PR branches
  • Loading branch information
cwolf10 committed Sep 16, 2024
2 parents 4aa1fd4 + 0266d57 commit fe308b9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 12 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/build-and-deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ on:
branches:
- master
jobs:
Build-And-Deploy:
Build-Storybook:
uses: ./.github/workflows/build.yml
Deploy-Storybook:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: Build-Storybook
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
- name: Download Storybook Assets
# If closing PR, build will not occur so nothing to download
if: github.event.action != 'closed'
uses: actions/download-artifact@v4
with:
node-version: '18.x'
- name: Install Node Packages
run: npm i
- name: Build Storybook Assets
env:
NODE_OPTIONS: "--max_old_space_size=8192"
run: npm run build:storybook
- name: Add .nojekyll file to allow for node_modules to be included in bundle
run: touch _site/.nojekyll
name: storybook-assets
path: ./_site
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: _site
clean-exclude: pr-preview/
force: false
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Storybook
on:
workflow_call:
inputs:
pr-number:
required: false
type: string
jobs:
Build-Storybook-Assets:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Install Node Packages
run: npm i
- name: Build Storybook Assets
run: npm run build:storybook
env:
NODE_OPTIONS: "--max_old_space_size=8192"
- name: Add .nojekyll file to allow for node_modules to be included in bundle
run: touch _site/.nojekyll
- name: Archive Storybook Assets
uses: actions/upload-artifact@v4
with:
name: storybook-assets
path: _site
retention-days: 1
33 changes: 33 additions & 0 deletions .github/workflows/pr-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy PRs
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
jobs:
Build-Storybook:
if: github.event.action != 'closed'
uses: ./.github/workflows/build.yml
with:
pr-number: ${{ github.event.number }}
Deploy-Storybook:
runs-on: ubuntu-latest
if: ${{ !failure() }}
needs: Build-Storybook
steps:
# Only needed because rossjrw/pr-preview-action needs to run in a git repo
- name: Check out repository code
uses: actions/checkout@v4
- name: Download Storybook Assets
# If closing PR, build will not occur so nothing to download
if: github.event.action != 'closed'
uses: actions/download-artifact@v4
with:
name: storybook-assets
path: ./_site
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./_site/

0 comments on commit fe308b9

Please sign in to comment.