Skip to content

Test - Integration - ROSA Daily cleanup #93

Test - Integration - ROSA Daily cleanup

Test - Integration - ROSA Daily cleanup #93

name: "Test - Integration - ROSA Daily cleanup"
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"
default: "20"
schedule:
- cron: '0 1 * * *' # At 01:00 everyday.
env:
MAX_AGE_HOURS_CLUSTER: 20
# please keep those variables synced with test-integration-rosa.yml
TEST_AWS_REGION: "eu-central-1"
TF_S3_BUCKET: "${{ secrets.DISTRO_CI_OPENSHIFT_TFSTATE_BUCKET }}"
jobs:
cleanup-clusters:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Checkout Repository rosa modules
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 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@main
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: Notify in Slack in case of failure
id: slack-notification
if: failure() && github.event_name == 'schedule'
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"unfurl_links": false,
"unfurl_media": false,
"text": "${{ github.event.repository.name }} (${{ github.server_url }}/${{ github.repository }}) scheduled workflow: ${{ github.workflow }} failed! Please check: ${{ env.WORKFLOW_URL }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":automation-platform-failure: :mechanic: <${{ github.server_url }}/${{ github.repository }}|[${{ github.event.repository.name }}]> scheduled workflow: ${{ github.workflow }} failed! \n :link: Please check: ${{ env.WORKFLOW_URL }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.DISTRO_CI_SLACK_BOT_TOKEN }}
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"