name: Cleanup environments

on:
  pull_request:
    types:
      - closed
      - merged
  workflow_dispatch:

jobs:
  cleanup_release:
    uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_helmfile.yaml@master
    with:
      appName: review-l2-$GITHUB_REF_NAME_SLUG
      globalEnv: review
      helmfileDir: deploy
      kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev
      vaultRole: ci-dev
    secrets: inherit
  cleanup_l2_release:
    uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_helmfile.yaml@master
    with:
      appName: review-$GITHUB_REF_NAME_SLUG
      globalEnv: review
      helmfileDir: deploy
      kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev
      vaultRole: ci-dev
    secrets: inherit
  cleanup_docker_image:
    uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_docker.yaml@master
    with:
      dockerImage: review-$GITHUB_REF_NAME_SLUG
    secrets: inherit
