Skip to content

Destroy Expired Environment #156

Destroy Expired Environment

Destroy Expired Environment #156

name: Destroy Expired Environment
on:
# Schedule to run every day at 00:00 UTC
schedule:
- cron: '0 0 * * *'
jobs:
envs_to_destroy:
runs-on: ubuntu-latest
outputs:
matrix_deployments: ${{ steps.get_expired_envs.outputs.deployments }}
env_found: ${{ steps.get_expired_envs.outputs.expired_env_found }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Hermit Environment
uses: ./.github/actions/hermit
with:
init-tools: 'true'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "eu-west-1"
- name: Get expired environments
id: get_expired_envs
run: |
.ci/scripts/get_expired_envs.sh
destroy_environment:
uses: ./.github/workflows/destroy-environment.yml
needs: ["envs_to_destroy"]
secrets: inherit
# Required for the 'Destroy' job in the 'destroy-environment.yml'
permissions:
contents: 'read'
id-token: 'write'
if: ${{ needs.envs_to_destroy.outputs.env_found == 'true' }}
strategy:
fail-fast: false
max-parallel: 1 # Destroy environments one by one
matrix:
deployment_name: ${{fromJson(needs.envs_to_destroy.outputs.matrix_deployments)}}
with:
prefix: ${{ matrix.deployment_name }}