Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create a reusable gha for cleanup clusters #9

Merged
merged 7 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading