-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
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 | ||
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/[email protected] | ||
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/[email protected] | ||
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 }})." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters