name: Feature Branch un-Deployment

on:
  pull_request:
    types:
      - closed

env:
  PR_NUMBER: ${{ github.event.number }}

jobs:
  undeploy-dev:
    if: ${{ !contains(fromJSON('["main", "dev", "staging", "prod"]'), github.head_ref) }}
    runs-on: [self-hosted, dev]
    steps:
      - name: un-Deploy dev Branch Testing Environment
        run: docker compose -f ./docker-compose.pr.yml down

  undeploy-staging:
    if: ${{ !contains(fromJSON('["main", "dev", "staging", "prod"]'), github.head_ref) }}
    runs-on: [self-hosted, staging]
    steps:
      - name: un-Deploy staging Branch Testing Environment
        run: docker compose -f ./docker-compose.pr.yml down
