diff --git a/.github/workflows/.deployer.yml b/.github/workflows/.deployer.yml index e4166a73..5157e848 100644 --- a/.github/workflows/.deployer.yml +++ b/.github/workflows/.deployer.yml @@ -48,6 +48,7 @@ env: AWS_REGION: ca-central-1 jobs: infra: + environment: ${{ inputs.environment_name }} name: Terraform ${{inputs.command}} runs-on: ubuntu-24.04 outputs: diff --git a/.github/workflows/.destroy.yml b/.github/workflows/.destroy.yml new file mode 100644 index 00000000..a3e9f63b --- /dev/null +++ b/.github/workflows/.destroy.yml @@ -0,0 +1,43 @@ +name: .Terraform Destroyer + +on: + workflow_call: + inputs: + ### Required + environment_name: + description: 'The name of the environment to destroy resources from dev or test or prod(BE CAREFUL HERE)' + required: true + default: 'dev' + type: string + app_env: + required: false + type: string + description: 'The APP env separates between AWS ENV and Actual APP, since AWS dev is where PR, and TEST is deployed' +jobs: + cleanup-aws-database: + name: Cleanup AWS Database + uses: ./.github/workflows/.deployer.yml + with: + environment_name: ${{ inputs.environment_name}} + command: destroy + working_directory: database + + secrets: inherit + cleanup-aws-api: + name: Cleanup AWS API + uses: ./.github/workflows/.deployer.yml + with: + environment_name: ${{ inputs.environment_name}} + command: destroy + working_directory: api + app_env: ${{ inputs.app_env}} + secrets: inherit + cleanup-aws-cf: + name: Cleanup AWS CF + uses: ./.github/workflows/.deployer.yml + with: + environment_name: ${{ inputs.environment_name}} + command: destroy + working_directory: frontend + app_env: ${{ inputs.app_env}} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pr-close.yml b/.github/workflows/pr-close.yml index 179f8234..f0c2f04f 100644 --- a/.github/workflows/pr-close.yml +++ b/.github/workflows/pr-close.yml @@ -13,31 +13,11 @@ permissions: packages: write pull-requests: write jobs: - cleanup-aws-database: - name: Cleanup AWS Database - uses: ./.github/workflows/.deployer.yml - with: - environment_name: dev - command: destroy - working_directory: database - - secrets: inherit - cleanup-aws-api: - name: Cleanup AWS API - uses: ./.github/workflows/.deployer.yml - with: - environment_name: dev - command: destroy - working_directory: api - app_env: ${{github.event.number}} - secrets: inherit - cleanup-aws-cf: - name: Cleanup AWS CF - uses: ./.github/workflows/.deployer.yml - with: - environment_name: dev - command: destroy - working_directory: frontend - tag: ${{ github.event.number }}-${{ github.run_number }} - app_env: ${{github.event.number}} - secrets: inherit \ No newline at end of file + cleanup: + name: Cleanup + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: TODO GHA for PR CLeanup on PR close + run: echo "TODO GHA for PR CLeanup on PR close"