Merge pull request #198 from rtCamp/update/artifact-version #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to GH Pages | |
on: | |
push: | |
# Don't run for irrelevant changes. | |
paths-ignore: | |
- 'docs/**' | |
- '!.github/workflows/deploy-storybook.yml' | |
- '.storybook/**' | |
- '.wordpress-org/**' | |
- '__mocks__/**' | |
- '__static__/**' | |
- 'bin/**' | |
- 'tests/**' | |
branches: | |
- main | |
jobs: | |
build-storybook: | |
name: Build storybook | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Cancel previous | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Read .nvmrc | |
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | |
id: nvm | |
- name: Setup Node | |
uses: actions/[email protected] | |
with: | |
node-version: '${{ steps.nvm.outputs.NVMRC }}' | |
- name: Cache node modules | |
uses: pat-s/[email protected] | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
env: | |
cache-name: cache-node-modules | |
- name: Install dependencies | |
run: npm ci | |
env: | |
CI: true | |
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true | |
- name: Build storyook | |
run: npm run storybook:build | |
- name: Upload storybook | |
uses: actions/upload-artifact@v4 | |
with: | |
name: storybook-files | |
path: build/storybook | |
deploy-gh-pages: | |
name: Deploy storybook | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
needs: [build-storybook] | |
steps: | |
- name: Cancel previous | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: gh-pages | |
- name: Download storybook files | |
uses: actions/download-artifact@v4 | |
with: | |
name: storybook-files | |
path: storybook-files | |
- name: Move storybook assets | |
run: | | |
mkdir -p storybook | |
rm -rf storybook/* | |
mv storybook-files/* storybook/ | |
- name: Commit updates | |
run: | | |
git add . | |
git status | |
git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0 | |
git commit -m "Deploy storybook for ${{ github.sha }}" | |
git pull --no-edit --quiet | |
git push origin gh-pages | |
env: | |
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com | |
GIT_AUTHOR_NAME: ${{ github.actor }} | |
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com | |
GIT_COMMITTER_NAME: ${{ github.actor }} |