Skip to content

docs: add slack notification #5

docs: add slack notification

docs: add slack notification #5

name: Cluster Scanner
on:
# For test purposes. Trigger it on pushes to the cluster-scanner branch.
push:
branches:
- cluster-scanner
# It runs every Friday, 9:30 UTC. The schedule job only works if the workflow is available in the main branch.
#schedule:
# - cron: "30 9 * * 5"
workflow_dispatch:
env:
PALETTE_API_KEY: ${{ secrets.PALETTE_API_KEY }}
PALETTE_HOST: ${{ secrets.PALETTE_HOST }}
PALETTE_PROJECT_UID: ${{ secrets.PALETTE_PROJECT_UID }}
jobs:
scan-clusters:
name: cluster-scan
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Up Go
uses: actions/setup-go@v5
with:
go-version-file: "scripts/cluster-scanner/go.mod"
- name: Install dependencies
working-directory: scripts/cluster-scanner
run: go get ./...
- name: Execute tests
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: |
if grep -q "The following clusters have been running for more than 24 hours" result.log; then
echo "CLUSTERS_FOUND=true" >> $GITHUB_ENV
fi
- name: Send Slack notification
if: env.CLUSTERS_FOUND == 'true'
uses: rtCamp/[email protected]
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)