From 1ebb7ec59d615587627284a69ef9895697e5b051 Mon Sep 17 00:00:00 2001 From: Carolina Delwing Rosa Date: Mon, 23 Dec 2024 13:49:34 -0300 Subject: [PATCH] docs: add slack notification --- .github/workflows/cluster_scanner.yaml | 39 ++++++++++++++++++-------- .gitignore | 3 ++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cluster_scanner.yaml b/.github/workflows/cluster_scanner.yaml index ba9220e..6e35426 100644 --- a/.github/workflows/cluster_scanner.yaml +++ b/.github/workflows/cluster_scanner.yaml @@ -29,20 +29,37 @@ jobs: go-version-file: "scripts/cluster-scanner/go.mod" - name: Install dependencies - run: | - cd scripts/cluster-scanner/ - go get ./... + working-directory: scripts/cluster-scanner + run: go get ./... - name: Execute tests - run: | - cd scripts/cluster-scanner/ - go test ./... + working-directory: scripts/cluster-scanner + run: go test ./... - name: Execute the cluster scanner application + id: run_cluster_scanner + working-directory: scripts/cluster-scanner + run: go run . | tee result.log + + - name: Check if clusters have been running for more than 24 hours + id: check_running_clusters + working-directory: scripts/cluster-scanner run: | - cd scripts/cluster-scanner/ - go run . + if grep -q "The following clusters have been running for more than 24 hours" result.log; then + echo "CLUSTERS_FOUND=true" >> $GITHUB_ENV + fi - # Get the output - # Ignore Slack output if there are no clusters running - # Send slack notification if output is different than what was planned + - name: Send Slack notification + if: env.CLUSTERS_FOUND == 'true' + uses: rtCamp/action-slack-notify@v2.3.2 + with: + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_TOKEN: ${{ secrets.SLACK_PRIVATE_TEAM_TOKEN }} + #SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }} + SLACK_USERNAME: "spectromate" + SLACK_ICON_EMOJI: ":robot_face:" + SLACK_COLOR: "good" + SLACKIFY_MARKDOWN: true + ENABLE_ESCAPES: true + MESSAGE: | + $(cat scripts/cluster-scanner/result.log) diff --git a/.gitignore b/.gitignore index 9b8a46e..7242c7f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ override.tf.json # Ignore CLI configuration files .terraformrc terraform.rc + +# Ignore secrets +.secrets \ No newline at end of file