Skip to content

ci: add openshift on-demand cluster tests #4

ci: add openshift on-demand cluster tests

ci: add openshift on-demand cluster tests #4

---
name: Daily cleanup ROSA cluster
on:
pull_request:
paths:
- '.github/workflows/daily-cleanup-rosa.yml'
- '.github/templates/issue_delete_clusters_failed.md'
workflow_dispatch:
inputs:
max_age_hours_cluster:
description: "Maximum age of clusters in hours"
required: true
default: "20"
schedule:
- cron: '0 1 * * *' # At 01:00 everyday.
env:
MAX_AGE_HOURS_CLUSTER: 20
# please keep those variables synced with test-integration-template.yml
TEST_AWS_REGION: "eu-central-1"
TF_S3_BUCKET: "${{ secrets.DISTRO_CI_OPENSHIFT_TFSTATE_BUCKET }}"
ASSIGNEES_ISSUE_ERROR: "aabouzaid, jessesimpson36, hamza-m-masood"
jobs:
cleanup-clusters:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Checkout Repository rosa modules
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
with:
repository: "camunda/camunda-tf-rosa"
ref: "main"
path: "./.rosa-hcp"
fetch-depth: 0
# Official action does not support profiles
- name: Authenticate to AWS
run: |
aws configure set aws_access_key_id ${{ secrets.DISTRO_CI_AWS_ACCESS_KEY }} --profile=${{ secrets.DISTRO_CI_AWS_PROFILE }}
aws configure set aws_secret_access_key ${{ secrets.DISTRO_CI_AWS_SECRET_KEY }} --profile=${{ secrets.DISTRO_CI_AWS_PROFILE }}
aws configure set region ${{ env.TEST_AWS_REGION }} --profile=${{ secrets.DISTRO_CI_AWS_PROFILE }}
- name: Delete clusters
id: delete_clusters
uses: camunda/camunda-tf-rosa/.github/actions/rosa-cleanup-clusters@feature/delete-clusters-action
timeout-minutes: 125
env:
RH_TOKEN: "${{ secrets.DISTRO_CI_REDHAT_CONSOLE_TOKEN }}"
AWS_REGION: "${{ env.TEST_AWS_REGION }}"
AWS_PROFILE: "${{ secrets.DISTRO_CI_AWS_PROFILE }}"
with:
tf-bucket: "${{ env.TF_S3_BUCKET }}-${{ env.TEST_AWS_REGION }}"
max-age-hours-cluster: "${{ env.MAX_AGE_HOURS_CLUSTER }}"
- name: Close issue in case of success
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
issue_url=$(gh --repo "${{ github.repository }}" search issues "Failed to cleanup ROSA clusters" --state=open --label="schedule" --json 'url' | jq '.[0].url' -r)
if [ "$issue_url" != "null" ]; then
gh issue close --comment "Auto-closing issue as the cleanup has been successfuly ran in ${{ env.WORKFLOW_URL }}." "$issue_url"
else
echo "No open issues found with the specified criteria."
fi
- name: Create issue on failure
if: failure()
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
with:
assignees: "${{ env.ASSIGNEES_ISSUE_ERROR }}"
update_existing: true
search_existing: all
filename: .github/templates/issue_delete_clusters_failed.md