Delete Dev Environment #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Delete Dev Environment" | |
on: | |
workflow_dispatch: | |
schedule: | |
# 17:00 UTC = 22:00 EST | |
- cron: "0 22 * * 5" | |
defaults: | |
run: | |
shell: bash | |
env: | |
AWS_REGION: ca-central-1 | |
AWS_NUKE_VERSION: 3.24.0 | |
AWS_NUKE_CONFIG_PLACEHOLDER: SCRATCH_ACCOUNT_ID | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
ENVIRONMENT: dev | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
jobs: | |
delete-dev-environment: | |
if: | | |
always() && | |
!contains(needs.*.result, 'cancelled') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
- name: setup-terraform | |
uses: ./.github/actions/setup-terraform | |
with: | |
role_to_assume: arn:aws:iam::${{ secrets.DEV_ACCOUNT_ID}}:role/notification-terraform-apply | |
role_session_name: NotifyTerraformDestroy | |
- name: Install AWS nuke | |
run: | | |
mkdir bin | |
curl -Lo aws-nuke.tar.gz https://github.com/ekristen/aws-nuke/releases/download/v${{ env.AWS_NUKE_VERSION }}/aws-nuke-v${{ env.AWS_NUKE_VERSION }}-linux-amd64.tar.gz | |
tar -xzf aws-nuke.tar.gz -C bin | |
chmod +x bin/* | |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | |
- name: Install 1Pass CLI | |
run: | | |
curl -o 1pass.deb https://downloads.1password.com/linux/debian/amd64/stable/1password-cli-amd64-latest.deb | |
sudo dpkg -i 1pass.deb | |
- name: Fetch secrets from 1Password | |
run: | | |
op read op://4eyyuwddp6w4vxlabrr2i2duxm/"TERRAFORM_SECRETS_DEV"/notesPlain > aws/dev.tfvars | |
- name: Destroy notify dev environment | |
run: | | |
cd scripts | |
./deleteEnvironment.sh dev ${{ secrets.DEV_ACCOUNT_ID}} |