Run Mainnet Check and Notify Slack #15476
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
## | |
## Copyright 2024 Ocean Protocol Foundation | |
## SPDX-License-Identifier: Apache-2.0 | |
## | |
name: Run Mainnet Check and Notify Slack | |
on: | |
schedule: | |
- cron: "*/30 * * * *" | |
workflow_dispatch: | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Check if current time is between 00:00 and 01:00 | |
run: | | |
current_hour=$(date -u +"%H") | |
if [ "$current_hour" -ge 0 ] && [ "$current_hour" -lt 1 ]; then | |
echo "Current time is between 00:00 and 01:00, exiting..." | |
exit 0 | |
fi | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.11" | |
- name: Fetch the address file and move it to contracts directory | |
run: | | |
wget https://raw.githubusercontent.com/oceanprotocol/contracts/main/addresses/address.json | |
mkdir -p ~/.ocean/ocean-contracts/artifacts/ | |
mv address.json ~/.ocean/ocean-contracts/artifacts/ | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Notify Slack | |
run: | | |
output=$(python pdr check_network ppss.yaml sapphire-mainnet 2>&1 || true) | |
echo "$output" | |
filtered_output=$(echo "$output" | grep -E 'FAIL|ERROR|error|Error' || true) | |
if [ -z "$filtered_output" ]; then | |
echo "No output, so no message will be sent to Slack" | |
else | |
joke_response=$(curl -s "https://v2.jokeapi.dev/joke/Any?type=single") | |
joke=$(echo "$joke_response" | jq -r '.joke') | |
message="🙀 Mainnet Check script failed: \n${filtered_output}\n\nHere's a joke:\n$joke\n" | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"'"$message"'"}' ${{ secrets.SLACK_WEBHOOK_URL_MAINNET }} | |
fi |