From da1af4c9ecef7d745d6c26f492ddb52e10a67ca7 Mon Sep 17 00:00:00 2001 From: Wil Clouser Date: Tue, 30 Apr 2024 11:42:08 -0700 Subject: [PATCH] chore(storybook): see about building storybooks with actions Because: * Our current system uses a one-off library that is unmaintained This commit: * Tries building storybook with Github Actions --- .github/workflows/deploy-storybook.yml | 95 ++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/deploy-storybook.yml diff --git a/.github/workflows/deploy-storybook.yml b/.github/workflows/deploy-storybook.yml new file mode 100644 index 00000000000..3a8828c3c7d --- /dev/null +++ b/.github/workflows/deploy-storybook.yml @@ -0,0 +1,95 @@ +name: "Build & Deploy Storybook" +on: [push] +permissions: + contents: read + pages: write + statuses: write +jobs: + storybook: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install and Build 🔧 + run: yarn install + run: npx nx run-many -t build-storybook + + - name: Deploy fxa-auth-server storybook... 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: packages/fxa-auth-server/storybook-static + target-folder: storybooks/${{ github.head_ref || github.ref_name }}/fxa-auth-server + + - name: Deploy fxa-react storybook... 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: packages/fxa-react/storybook-static + target-folder: storybooks/${{ github.head_ref || github.ref_name }}/fxa-react + + - name: Deploy fxa-settings storybook... 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: packages/fxa-settings/storybook-static + target-folder: storybooks/${{ github.head_ref || github.ref_name }}/fxa-settings + + - name: Deploy fxa-payments-server storybook... 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: packages/fxa-payments-server/storybook-static + target-folder: storybooks/${{ github.head_ref || github.ref_name }}/fxa-payments-server + + - name: Get Github Pages Base URL + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + githubPagesUrl="$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url')" + echo 'GITHUB_PAGES_URL='$githubPagesUrl >> $GITHUB_ENV + + - name: Create fxa-auth-server Status Check + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ github.event.pull_request.head.sha || github.sha }} + state: 'success' + context: 'Storybook Deployment - fxa-auth-server' + description: 'Storybook Deployment for ${{ github.head_ref || github.ref_name }}' + target_url: '${{ env.GITHUB_PAGES_URL }}storybooks/${{ github.head_ref || github.ref_name }}/fxa-auth-server/index.html' + + - name: Create fxa-react Status Check + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ github.event.pull_request.head.sha || github.sha }} + state: 'success' + context: 'Storybook Deployment - fxa-react' + description: 'Storybook Deployment for ${{ github.head_ref || github.ref_name }}' + target_url: '${{ env.GITHUB_PAGES_URL }}storybooks/${{ github.head_ref || github.ref_name }}/fxa-react/index.html' + + - name: Create fxa-settings Status Check + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ github.event.pull_request.head.sha || github.sha }} + state: 'success' + context: 'Storybook Deployment - fxa-settings' + description: 'Storybook Deployment for ${{ github.head_ref || github.ref_name }}' + target_url: '${{ env.GITHUB_PAGES_URL }}storybooks/${{ github.head_ref || github.ref_name }}/fxa-settings/index.html' + + - name: Create fxa-payments-server Status Check + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ github.event.pull_request.head.sha || github.sha }} + state: 'success' + context: 'Storybook Deployment - fxa-payments-server' + description: 'Storybook Deployment for ${{ github.head_ref || github.ref_name }}' + target_url: '${{ env.GITHUB_PAGES_URL }}storybooks/${{ github.head_ref || github.ref_name }}/fxa-payments-server/index.html'