Skip to content

Run Script and Notify Slack #520

Run Script and Notify Slack

Run Script and Notify Slack #520

Workflow file for this run

name: Run Script and Notify Slack
on:
#schedule:
# - cron: "17 * * * 7"
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
run: |
output=$(python pdr check_network ppss.yaml sapphire-testnet | 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