Run Mainnet Check and Notify Slack #5135
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
name: Run Mainnet Check and Notify Slack | |
on: | |
schedule: | |
- cron: "17 * * * *" | |
workflow_dispatch: | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
ref: ba241caa6554d6b0444a501ec0f884f43d59abf2 | |
- 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 | grep -E 'FAIL|WARNING|error' || true) | |
if [ -z "$output" ]; then | |
echo "No output, so no message will be sent to Slack" | |
else | |
trivia_response=$(curl -s "https://opentdb.com/api.php?amount=1&difficulty=medium&type=multiple&category=18") | |
question=$(echo "$trivia_response" | jq -r '.results[0].question') | |
correct_answer=$(echo "$trivia_response" | jq -r '.results[0].correct_answer') | |
incorrect_answers=$(echo "$trivia_response" | jq -r '.results[0].incorrect_answers[]' | paste -sd "," -) | |
IFS=',' read -r -a answers <<< "$correct_answer,$incorrect_answers" | |
shuffled_answers=($(shuf -e "${answers[@]}")) | |
options=("A" "B" "C" "D") | |
shuffled_options=() | |
for i in "${!shuffled_answers[@]}"; do | |
shuffled_options+=("${options[$i]}: ${shuffled_answers[$i]}") | |
done | |
trivia_message="Trivia question: $question\nOptions:\n${shuffled_options[0]}\n${shuffled_options[1]}\n${shuffled_options[2]}\n${shuffled_options[3]}\n" | |
message="Mainnet Check script failed: \n${output}\n\n${trivia_message}" | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"'"$message"'"}' ${{ secrets.SLACK_WEBHOOK_URL_MAINNET }} | |
fi |