diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ec656436ee7..98eb0aee15a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1275,6 +1275,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/i18n-crowdin-download.yml @grafana/grafana-frontend-platform /.github/workflows/i18n-crowdin-create-tasks.yml @grafana/grafana-frontend-platform /.github/workflows/i18n-verify.yml @grafana/grafana-frontend-platform +/.github/workflows/deploy-storybook.yml @grafana/grafana-frontend-platform /.github/workflows/deploy-storybook-preview.yml @grafana/grafana-frontend-platform /.github/workflows/scripts/crowdin/create-tasks.ts @grafana/grafana-frontend-platform /.github/workflows/scripts/publish-frontend-metrics.mts @grafana/grafana-frontend-platform diff --git a/.github/workflows/deploy-storybook.yml b/.github/workflows/deploy-storybook.yml new file mode 100644 index 00000000000..08bffaeb891 --- /dev/null +++ b/.github/workflows/deploy-storybook.yml @@ -0,0 +1,79 @@ +name: Deploy Storybook + +on: + workflow_dispatch: + # push: + # branches: + # - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: {} + +jobs: + detect-changes: + # Only run in grafana/grafana + if: github.repository == 'grafana/grafana' + name: Detect whether code changed + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + changed-frontend-packages: ${{ steps.detect-changes.outputs.frontend-packages }} + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: true # required to get more history in the changed-files action + fetch-depth: 2 + - name: Detect changes + id: detect-changes + uses: ./.github/actions/change-detection + with: + self: .github/workflows/deploy-storybook.yml + deploy-storybook: + name: Deploy Storybook + runs-on: ubuntu-latest + needs: detect-changes + # Only run in grafana/grafana + if: github.repository == 'grafana/grafana' && needs.detect-changes.outputs.changed-frontend-packages == 'true' + permissions: + contents: read + id-token: write + + env: + BUCKET_NAME: grafana-storybook + + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Setup Node.js + uses: ./.github/actions/setup-node + + - name: Install dependencies + run: yarn install --immutable + + - name: Build storybook + run: yarn storybook:build + + # Create the GCS folder name + # Right now, this just returns "canary" + # But we'll expand this to work for "latest" as well in the future + - name: Create deploy name + id: create-deploy-name + run: | + echo "deploy-name=canary" >> "$GITHUB_OUTPUT" + + - name: Upload Storybook + uses: grafana/shared-workflows/actions/push-to-gcs@main + with: + environment: prod + bucket: ${{ env.BUCKET_NAME }} + bucket_path: ${{ steps.create-deploy-name.outputs.deploy-name }} + path: packages/grafana-ui/dist/storybook + service_account: github-gf-storybook-deploy@grafanalabs-workload-identity.iam.gserviceaccount.com + parent: false