Skip to content

Commit

Permalink
Merge pull request #7 from bcgov/chore/misc
Browse files Browse the repository at this point in the history
chore: remove destroy from pr close to avoid accidents and add environment tag to the job in deployer
  • Loading branch information
mishraomp authored Dec 12, 2024
2 parents cba4adf + 830f910 commit 7374b64
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/workflows/.deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/.destroy.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 8 additions & 28 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"

0 comments on commit 7374b64

Please sign in to comment.