Skip to content

Commit

Permalink
feat: create a reusable gha for cleanup clusters (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
leiicamundi authored May 31, 2024
1 parent 4b6665c commit 34eef55
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
22 changes: 22 additions & 0 deletions .github/actions/rosa-cleanup-clusters/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Delete ROSA Clusters

description: |
This GitHub Action automates the deletion of ROSA (Red Hat OpenShift Service on AWS) clusters using a shell script.
inputs:
tf-bucket:
description: 'Bucket containing the clusters states'
required: true
max-age-hours-cluster:
description: 'Maximum age of clusters in hours'
required: false
default: "20"

runs:
using: 'composite'
steps:
- name: Delete clusters
id: delete_clusters
shell: bash
run: |
${{ github.action_path }}/scripts/destroy-clusters.sh "${{ inputs.tf-bucket }}" ${{ github.action_path }}/../../../modules/rosa-hcp/ /tmp/rosa/ ${{ inputs.max-age-hours-cluster }}
15 changes: 10 additions & 5 deletions .github/workflows/daily-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ on:
description: "Maximum age of clusters in hours"
required: true
default: "20"
pull_request:
# the paths should be synced with ../labeler.yml
paths:
- .github/workflows/daily-cleanup.yml
- .github/actions/rosa-cleanup-clusters/**

schedule:
- cron: '0 1 * * *' # At 01:00 everyday.

env:
MAX_AGE_HOURS_CLUSTER: 20
MAX_AGE_HOURS_CLUSTER: "${{ github.event.inputs.max_age_hours_cluster || '20' }}"
AWS_PROFILE: "infex"

# please keep those variables synced with tests.yml
Expand Down Expand Up @@ -63,13 +68,13 @@ jobs:
- name: Delete clusters
id: delete_clusters
timeout-minutes: 125
shell: bash
uses: ./.github/actions/rosa-cleanup-clusters
env:
RH_TOKEN: "${{ steps.secrets.outputs.RH_OPENSHIFT_TOKEN }}"
AWS_REGION: "${{ env.TESTS_AWS_REGION }}"
MAX_AGE_HOURS_CLUSTER: ${{ github.event.inputs.max_age_hours_cluster || env.MAX_AGE_HOURS_CLUSTER }}
run: |
.github/workflows/scripts/destroy-clusters.sh "${{ env.TF_S3_BUCKET }}" ./modules/rosa-hcp/ /tmp/rosa/ ${{ env.MAX_AGE_HOURS_CLUSTER }}
with:
tf-bucket: "${{ env.TF_S3_BUCKET }}"
max-age-hours-cluster: "${{ env.MAX_AGE_HOURS_CLUSTER }}"

- name: Close issue in case of success
shell: bash
Expand Down

0 comments on commit 34eef55

Please sign in to comment.