Skip to content

Destroy Expired Environment #608

Destroy Expired Environment

Destroy Expired Environment #608

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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Hermit Environment
uses: ./.github/actions/hermit
with:
init-tools: "true"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # 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: ${{fromJson(needs.envs_to_destroy.outputs.matrix_deployments)}}
with:
prefix: ${{ matrix.deployment.deployment_name }}