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

chore: first test cluster scanner #5538

Merged
merged 8 commits into from
Jan 23, 2025
87 changes: 87 additions & 0 deletions .github/workflows/cluster-scanner-librarium.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Cluster Scanner

on:
# Every Tuesday and Friday at 17 UTC
schedule:
- cron: "0 17 * * 2,5"
workflow_dispatch:

jobs:
caroldelwing marked this conversation as resolved.
Show resolved Hide resolved
scan-clusters:
name: cluster-scan
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
environment: [PROD, DEV, STAGE]

steps:
- name: Checkout Palette Samples Repository
uses: actions/checkout@v4
with:
repository: spectrocloud/palette-samples

- 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: Set Environment Variables Based on Environment
run: |
if [ "${{ matrix.environment }}" = "DEV" ]; then
echo "PALETTE_API_KEY=${{ secrets.SCAN_PALETTE_API_KEY_DEV }}" >> $GITHUB_ENV
echo "PALETTE_HOST=${{ secrets.SCAN_PALETTE_HOST_DEV }}" >> $GITHUB_ENV
elif [ "${{ matrix.environment }}" = "PROD" ]; then
echo "PALETTE_API_KEY=${{ secrets.SCAN_PALETTE_API_KEY_PROD }}" >> $GITHUB_ENV
echo "PALETTE_HOST=${{ secrets.SCAN_PALETTE_HOST_PROD }}" >> $GITHUB_ENV
else
echo "PALETTE_API_KEY=${{ secrets.SCAN_PALETTE_API_KEY_STAGE }}" >> $GITHUB_ENV
echo "PALETTE_HOST=${{ secrets.SCAN_PALETTE_HOST_STAGE }}" >> $GITHUB_ENV
fi
- name: Build and Run the App
working-directory: scripts/cluster-scanner
env:
PALETTE_API_KEY: ${{ env.PALETTE_API_KEY }}
PALETTE_HOST: ${{ env.PALETTE_HOST }}
run: |
set -e
go build -o cluster-scanner
./cluster-scanner | tee result.log
- name: Get Clusters With More Than 24 Hours and Format Output
working-directory: scripts/cluster-scanner
run: |
if grep -q "The following clusters have been running" result.log; then
caroldelwing marked this conversation as resolved.
Show resolved Hide resolved
echo "CLUSTERS_FOUND=true" >> $GITHUB_ENV
{
echo 'LOG_MESSAGE<<EOF'
echo "Palette Environment: ${{ matrix.environment }}"
sed 's/^.*msg=//' result.log | sed -n '/The following clusters/,/$/p' | sed 's/"//g'
echo EOF
} >> "$GITHUB_ENV"
fi
- name: Send Slack Notification
if: ${{ success() && env.CLUSTERS_FOUND == 'true' }}
uses: rtCamp/action-slack-notify@v2.3.2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }}
SLACK_COLOR: "good"
SLACKIFY_MARKDOWN: true
ENABLE_ESCAPES: true
SLACK_MESSAGE: ${{ env.LOG_MESSAGE }}

- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2.3.2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_PRIVATE_TEAM_WEBHOOK }}
SLACK_COLOR: "danger"
SLACKIFY_MARKDOWN: true
ENABLE_ESCAPES: true
SLACK_MESSAGE: "The cluster scan job for `${{ github.workflow }}` in `${{ github.repository }}` failed. [View details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
caroldelwing marked this conversation as resolved.
Show resolved Hide resolved
Loading