name: Deploy from main branch

on:
  push:
    branches:
      - main

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  publish_image:
    name: Publish Docker image
    uses: './.github/workflows/publish-image.yml'
    secrets: inherit

  deploy_main:
    name: Deploy frontend
    needs: publish_image
    uses: blockscout/blockscout-ci-cd/.github/workflows/deploy_helmfile.yaml@master
    with:
      appName: front
      globalEnv: main
      helmfileDir: deploy
      kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev
      vaultRole: ci-dev
    secrets: inherit

  deploy_l2:
    name: Deploy frontend (L2)
    needs: publish_image
    uses: blockscout/blockscout-ci-cd/.github/workflows/deploy_helmfile.yaml@master
    with:
      appName: l2-optimism-goerli
      globalEnv: optimism-goerli
      helmfileDir: deploy
      kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev
      vaultRole: ci-dev
    secrets: inherit
