Skip to content

Run Script and Notify Slack #513

Run Script and Notify Slack

Run Script and Notify Slack #513

Workflow file for this run

name: Run Script and Notify Slack
on:
schedule:
- cron: "17 * * * *"
workflow_dispatch:
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Notify Slack
env:
RPC_URL: "https://testnet.sapphire.oasis.dev"
SUBGRAPH_URL: "https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph"
PRIVATE_KEY: "0xb23c44b8118eb7a7f70d21b0d20aed9b05d85d22ac6a0e57697c564da1c35554"
run: |
output=$(python scripts/check_network.py 36 | grep -E 'FAIL|WARNING|error' | grep -v "1h" || true)
joke=$(curl -s https://official-joke-api.appspot.com/jokes/general/random | jq -r '.[0].setup, .[0].punchline')
if [ -z "$output" ]; then
echo "No output, so no message will be sent to Slack"
else
message="Testnet Check script failed: \n${output}\n\nHere's a funny joke to make your day: ${joke}"
curl -X POST -H 'Content-type: application/json' --data '{"text":"'"$message"'"}' ${{ secrets.SLACK_WEBHOOK_URL }}
fi