From 20c40fab41e808ef4ddf16aacd4de000c1f28380 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Tue, 9 Jul 2024 15:12:09 -0700 Subject: [PATCH] ci: firebase config for storybook ui Adds a deploy workflow for the new storybook ui static site, deploying to: * preview.ui.penumbra.zone, on merge to main * ui.penumbra.zone, on tag push Additionally, PRs will have an ephemeral URL for preview posted to them via a bot as a comment, so unmerged work can be viewed in an online context. --- .github/workflows/deploy-ui-preview-main.yml | 32 +++++++++++++++++++ .github/workflows/deploy-ui-preview-pr.yml | 33 ++++++++++++++++++++ .github/workflows/deploy-ui-release.yml | 33 ++++++++++++++++++++ packages/ui/.firebaserc | 19 +++++++++++ packages/ui/firebase.json | 22 +++++++++++++ 5 files changed, 139 insertions(+) create mode 100644 .github/workflows/deploy-ui-preview-main.yml create mode 100644 .github/workflows/deploy-ui-preview-pr.yml create mode 100644 .github/workflows/deploy-ui-release.yml create mode 100644 packages/ui/.firebaserc create mode 100644 packages/ui/firebase.json diff --git a/.github/workflows/deploy-ui-preview-main.yml b/.github/workflows/deploy-ui-preview-main.yml new file mode 100644 index 0000000000..4245176447 --- /dev/null +++ b/.github/workflows/deploy-ui-preview-main.yml @@ -0,0 +1,32 @@ +# Deploys the static website for the UI storybook to "preview" environment, +# on every merge into main branch. +name: Deploy UI to preview +on: + workflow_dispatch: + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - name: Install dependencies + run: pnpm install + working-directory: packages/ui + + - name: Build static site + run: pnpm build-storybook + working-directory: packages/ui + + - uses: FirebaseExtended/action-hosting-deploy@v0 + working-directory: packages/ui + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PENUMBRA_UI }} + channelId: live + target: preview + projectId: penumbra-ui diff --git a/.github/workflows/deploy-ui-preview-pr.yml b/.github/workflows/deploy-ui-preview-pr.yml new file mode 100644 index 0000000000..a3e61ba1e5 --- /dev/null +++ b/.github/workflows/deploy-ui-preview-pr.yml @@ -0,0 +1,33 @@ +# Deploys the static website for the UI storybook to a temporary environment, +# with an ephemeral URL posted to the PR for sharing/review. +name: Deploy UI to temporary URL +on: + workflow_dispatch: + pull_request: +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - name: Install dependencies + run: pnpm install + working-directory: packages/ui + + - name: Build static site + run: pnpm build-storybook + working-directory: packages/ui + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PENUMBRA_UI }} + target: preview + projectId: penumbra-ui diff --git a/.github/workflows/deploy-ui-release.yml b/.github/workflows/deploy-ui-release.yml new file mode 100644 index 0000000000..e8c6cdd8b2 --- /dev/null +++ b/.github/workflows/deploy-ui-release.yml @@ -0,0 +1,33 @@ +# Deploys the static website for the UI storybook to final prod website, +# on every tag push into main branch. +name: Deploy UI to stable channel +on: + # Support ad-hoc runs + workflow_dispatch: + # Run automatically on tag push + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - name: Install dependencies + run: pnpm install + working-directory: packages/ui + + - name: Build static site + run: pnpm build-storybook + working-directory: packages/ui + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PENUMBRA_UI }} + channelId: live + target: stable + projectId: penumbra-ui diff --git a/packages/ui/.firebaserc b/packages/ui/.firebaserc new file mode 100644 index 0000000000..2b58d9aa15 --- /dev/null +++ b/packages/ui/.firebaserc @@ -0,0 +1,19 @@ +{ + "projects": { + "default": "penumbra-ui" + }, + "targets": { + "penumbra-ui": { + "hosting": { + "preview": [ + "penumbra-ui-preview" + ], + "stable": [ + "penumbra-ui" + ] + } + } + }, + "etags": {}, + "dataconnectEmulatorConfig": {} +} \ No newline at end of file diff --git a/packages/ui/firebase.json b/packages/ui/firebase.json new file mode 100644 index 0000000000..6a13298b46 --- /dev/null +++ b/packages/ui/firebase.json @@ -0,0 +1,22 @@ +{ + "hosting": [ + { + "target": "preview", + "public": "storybook-static", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + }, + { + "target": "stable", + "public": "storybook-static", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } + ] +}