name: destroy on: workflow_dispatch: inputs: confirm_destroy: description: "Type the repository name to confirm destroy" required: true default: "" jobs: destroy: runs-on: - toolzoo-host env: AWS_REGION: us-east-1 APP_STACK_PREFIX: temp-stack steps: - name: Destroy stack and ECR images shell: bash run: | set -euo pipefail repo_full="${GITHUB_REPOSITORY}" owner_raw="${repo_full%%/*}" repo_raw="${repo_full##*/}" confirm="${{ github.event.inputs.confirm_destroy }}" if [[ "$confirm" != "$repo_raw" ]]; then echo "Refusing destroy: confirm_destroy must exactly match '$repo_raw'." exit 1 fi repo_slug="$(printf '%s' "$repo_raw" | tr '[:upper:]' '[:lower:]')" stack_name="${APP_STACK_PREFIX}-${repo_slug}" ecr_repo="temp/${repo_slug}" aws cloudformation delete-stack --stack-name "$stack_name" aws cloudformation wait stack-delete-complete --stack-name "$stack_name" if aws ecr describe-repositories --repository-names "$ecr_repo" >/dev/null 2>&1; then aws ecr delete-repository --repository-name "$ecr_repo" --force fi