Delete stale deployments #259
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: Clean up deployments | |
run-name: Delete stale deployments | |
on: | |
workflow_dispatch: | |
schedule: | |
# Every weekday at 10am | |
- cron: "0 10 * * 1-5" | |
permissions: | |
id-token: write | |
contents: read | |
concurrency: cleanup-dev-${{ github.head_ref || github.ref_name }} | |
jobs: | |
delete-stacks: | |
name: Delete stale stacks | |
runs-on: ubuntu-latest | |
environment: development | |
steps: | |
- name: Assume AWS Role | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ vars.DEPLOYMENT_ROLE_ARN }} | |
aws-region: eu-west-2 | |
- name: Get stale preview stacks | |
uses: govuk-one-login/github-actions/sam/get-stale-stacks@cd7d35dde348251237efbbaee5345e95adef0321 | |
with: | |
threshold-days: 14 | |
stack-name-filter: preview-kbv-hmrc-api | |
stack-tag-filters: | | |
cri:deployment-source=github-actions | |
cri:stack-type=preview | |
description: preview | |
env-var-name: STACKS | |
- name: Delete stacks | |
if: ${{ env.STACKS != null }} | |
uses: govuk-one-login/github-actions/sam/delete-stacks@cd7d35dde348251237efbbaee5345e95adef0321 | |
with: | |
stack-names: ${{ env.STACKS }} | |
verbose: true |