name: Build, release & deploy Formbricks images

on:
  workflow_dispatch:
  push:
    tags:
      - "v*"

jobs:
  docker-build:
    name: Build & release stable docker image
    if: startsWith(github.ref, 'refs/tags/v')
    uses: ./.github/workflows/release-docker-github.yml
    secrets: inherit

  helm-chart-release:
    name: Release Helm Chart
    uses: ./.github/workflows/release-helm-chart.yml
    secrets: inherit
    needs:
      - docker-build
    with:
      VERSION: ${{ needs.docker-build.outputs.VERSION }}

  deploy-formbricks-cloud:
    name: Deploy Helm Chart to Formbricks Cloud
    secrets: inherit
    uses: ./.github/workflows/deploy-formbricks-cloud.yml
    needs:
      - docker-build
      - helm-chart-release
    with:
      VERSION: v${{ needs.docker-build.outputs.VERSION }}
      ENVIRONMENT: "prod"
