betagouv/service-national-universel

View on GitHub
.github/workflows/destroy-environment-wip.yml

Summary

Maintainability
Test Coverage
name: Destroy environment

on:
  delete:
  workflow_dispatch:

defaults:
  run:
    working-directory: devops/scripts

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "18.20"

      - name: Get environment name
        id: env_name
        run: |
          env_name=$(node get-environment-name.js ${{ github.event.ref }})
          echo "env_name: $env_name"
          echo "env_name=$env_name" >> $GITHUB_OUTPUT

      - name: Destroy environment
        env:
          SCW_SECRET_KEY: ${{ secrets.SCW_CI_DEPLOY_SECRET_KEY }}
          SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }}
        run: node destroy-environment.js snu-custom ${{ steps.env_name.outputs.env_name }}