Create the button component with vanilla-extract #49
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: Storybook | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
on: | |
push: | |
branches: | |
- master | |
# Only run if relevant files changed. | |
paths: | |
- '.github/workflows/storybook.yml' | |
- 'src/**' | |
- 'stories/**' | |
- 'icons/**' | |
- '.storybook/**' | |
- '!.storybook/storybook-data.js' | |
- '**/package.json' | |
- 'package-lock.json' | |
pull_request: | |
branches: | |
- dev | |
- master | |
# Only run if relevant files changed. | |
paths: | |
- '.github/workflows/storybook.yml' | |
- 'src/**' | |
- 'stories/**' | |
- 'icons/**' | |
- '.storybook/**' | |
- '!.storybook/storybook-data.js' | |
- '**/package.json' | |
- 'package-lock.json' | |
types: | |
- opened | |
- closed | |
- reopened | |
- synchronize | |
- ready_for_review | |
concurrency: | |
group: storybook-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build Storybook | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
if: false == ( ( github.event_name == 'pull_request' && ( github.event.action == 'closed' || github.event.pull_request.draft == true || contains( github.head_ref, 'dependabot/' ) ) ) || github.event.pull_request.head.repo.fork ) | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
- name: yarn install | |
run: | | |
yarn install | |
- name: Build Storybook | |
run: | | |
yarn run storybook:build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: storybook-static | |
path: storybook-static | |
deploy: | |
name: Deploy Storybook | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: storybook-static | |
path: storybook-static | |
- name: Set branch environment variables | |
id: branch-target | |
if: github.event_name != 'pull_request' | |
run: echo "dir=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT | |
- name: Set PR environment variables | |
id: pr-target | |
if: github.event_name == 'pull_request' | |
env: | |
PULL_REQUEST_NUMBER: ${{ github.event.number }} | |
run: echo "dir=pr/${PULL_REQUEST_NUMBER}" >> $GITHUB_OUTPUT | |
- name: Deploy PR | |
if: github.event_name == 'pull_request' | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
mkdir -p ${TARGET_DIR} | |
rm -rf ${TARGET_DIR} | |
mv storybook-static ${TARGET_DIR} | |
git add . | |
git status | |
git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0 | |
git pull --no-edit --quiet | |
git commit -m "Deploy storybook for ${TARGET_DIR}." | |
git push origin gh-pages | |
env: | |
TARGET_DIR: ${{ steps.pr-target.outputs.dir }} | |
# - name: Deploy master | |
# if: github.event_name == 'push' | |
# run: | | |
# find . -maxdepth 1 -type f -delete | |
# mv storybook-static . | |
# git add . | |
# git status | |
# git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0 | |
# git pull --no-edit --quiet | |
# git commit -m "Deploy storybook for ${TARGET_DIR}." | |
# git push origin gh-pages | |
comment: | |
name: Comment with preview link | |
runs-on: ubuntu-latest | |
needs: deploy | |
if: ( github.event_name == 'pull_request' && github.event.action == 'open' && contains( github.head_ref, 'dependabot/' ) == false ) && github.event.pull_request.head.repo.fork == false | |
steps: | |
- uses: peter-evans/create-or-update-comment@v3 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Preview: | |
https://ooni.github.io/design-system/pr/${{ github.event.number }} | |
remove: | |
name: Remove Storybook | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
if: ( github.event_name == 'pull_request' && github.event.action == 'closed' && contains( github.head_ref, 'dependabot/' ) == false ) && github.event.pull_request.head.repo.fork == false | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Remove storybook | |
env: | |
PULL_REQUEST_NUMBER: ${{ github.event.number }} | |
run: | | |
git rm -rf /pr/${PULL_REQUEST_NUMBER} | |
git status | |
git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0 | |
git pull --no-edit --quiet | |
git commit -m "Remove storybook for pull/${PULL_REQUEST_NUMBER}." | |
git push origin gh-pages |