update alerts (#839)

* update alerts

* move py file

* delete old actions
This commit is contained in:
tarikceric 2025-05-12 11:37:53 -07:00 committed by GitHub
parent 21cb4f149e
commit f1afce74e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 391 additions and 243 deletions

View File

@ -73,3 +73,10 @@ jobs:
- name: push changes to docs
run: |
git push -f --set-upstream origin docs
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -65,3 +65,9 @@ jobs:
run: |
${{ matrix.command }}
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -1,46 +0,0 @@
name: dbt_run_backfill_transfers_mints
run-name: dbt_run_backfill_transfers_mints
on:
workflow_dispatch:
branches:
- "tmp-backfill-transfers-missing-mints"
schedule:
- cron: "*/3 * * * *"
env:
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:
group: ${{ github.workflow }}
jobs:
run_dbt_jobs:
runs-on: ubuntu-latest
environment:
name: workflow_prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ vars.PYTHON_VERSION }}"
cache: "pip"
- name: install dependencies
run: |
pip install -r requirements.txt
dbt deps
- name: Run DBT Jobs
run: |
dbt run -s silver__transfers_null_mints_fix -t dev

View File

@ -1,44 +0,0 @@
name: dbt_run_batch_backfill_2
run-name: dbt_run_batch_backfill_2
on:
workflow_dispatch:
branches:
- "main"
env:
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: DBT_EMERGENCY
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:
group: ${{ github.workflow }}
jobs:
run_dbt_jobs:
runs-on: ubuntu-latest
environment:
name: workflow_prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ vars.PYTHON_VERSION }}"
cache: "pip"
- name: install dependencies
run: |
pip install -r requirements.txt
dbt deps
- name: Run DBT Jobs
run: |
dbt run -s "solana_models,tag:events_inner_backfill"

View File

@ -49,3 +49,9 @@ jobs:
dbt run -s "solana_models,tag:nft_api"
dbt run -s "solana_models,tag:daily"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s models/streamline/decode_instructions/streamline__decode_instructions_3_realtime.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run-operation decoded_instructions_backill_cleanup_views
dbt run-operation decoded_instructions_backfill_calls --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -69,3 +69,10 @@ jobs:
run: |
dbt run-operation dispatch_github_workflow --args "{'workflow_name': 'dbt_run_decode_instructions_backfill'}"
if: ${{ github.event_name == 'workflow_dispatch' && contains(fromJSON('["50"]'), steps.capture_minute.outputs.formatted_minute) }}
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s models/streamline/decode_instructions/streamline__decode_instructions_3_pyth_realtime.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s models/streamline/decode_logs/streamline__decode_logs_2_realtime.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run-operation decoded_logs_backill_cleanup_views
dbt run-operation decoded_logs_backfill_calls --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -64,3 +64,10 @@ jobs:
run: |
dbt run-operation dispatch_github_workflow --args "{'workflow_name': 'dbt_run_decode_logs_backfill'}"
if: ${{ github.event_name == 'workflow_dispatch' && contains(fromJSON('["45"]'), steps.capture_minute.outputs.formatted_minute) }}
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -46,3 +46,10 @@ jobs:
run: |
dbt seed -s "solana_models,./data" --full-refresh
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"OBSERV_FULL_TEST":True}' -m "solana_models,models/silver/_observability"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,4 +44,11 @@ jobs:
run: |
dbt run -s models/silver/metadata/helius/silver__helius_nft_requests.sql models/bronze/bronze_api/bronze_api__helius_nft_metadata.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -s models/streamline/parser/history/streamline__idls_history.sql models/streamline/parser/history/streamline__complete_decoded_history.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
dbt run-operation run_sp_refresh_external_tables_full
dbt run -s "solana_models,tag:scheduled_core"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
dbt run-operation run_sp_refresh_external_tables_full
dbt run -s "solana_models,tag:scheduled_core"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -45,3 +45,9 @@ jobs:
dbt run-operation run_sp_refresh_external_tables_full
dbt run -s "solana_models,tag:scheduled_core" "solana_models,tag:scheduled_non_core"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -40,3 +40,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -s "solana_models,tag:scheduled_non_core_hourly"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -45,3 +45,10 @@ jobs:
dbt run-operation get_block_production
dbt run -s models/silver/validator/silver__snapshot_block_production_2.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run -s models/silver/nfts/silver__nft_compressed_mints_onchain.sql
dbt run -s models/silver/nfts/silver__nft_compressed_mints.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run-operation nft_compressed_mints_backfill_make_call
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -48,3 +48,10 @@ jobs:
dbt run -s models/bronze/bronze_api/bronze_api__parse_compressed_nft_mints.sql
dbt run -s models/bronze/bronze_api/bronze_api__parse_compressed_nft_mints.sql
dbt run -s models/bronze/bronze_api/bronze_api__parse_compressed_nft_mints.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -s models/bronze/bronze_api/bronze_api__parse_compressed_nft_sales_magic_eden.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -s models/bronze/bronze_api/bronze_api__parse_compressed_nft_sales_magic_eden.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -1,45 +0,0 @@
name: dbt_run_snapshot_validators
run-name: dbt_run_snapshot_validators
on:
workflow_dispatch:
schedule:
# Runs 02:22 daily (see https://crontab.guru)
- cron: '22 2 * * *'
env:
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:
group: ${{ github.workflow }}
jobs:
run_dbt_jobs:
runs-on: ubuntu-latest
environment:
name: workflow_prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ vars.PYTHON_VERSION }}"
cache: "pip"
- name: install dependencies
run: |
pip install -r requirements.txt
dbt deps
- name: Run DBT Jobs
run: |
dbt run -s "solana_models,tag:validator_2"

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -s bronze__stage_block_txs_2
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run -s models/streamline/core/complete/streamline__complete_block_rewards_2.sql
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s streamline__block_rewards_2
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s streamline__complete_block_txs_2 streamline__block_txs_2
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -42,3 +42,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s streamline__complete_blocks_2 streamline__blocks_2
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run -s streamline__complete_helius_cnft_metadata_requests
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s streamline__helius_cnft_metadata_requests
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
run: |
dbt run -s silver___blocks_tx_count
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS": True}' -s streamline__solscan_blocks
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
run: |
dbt run -s "solana_models,streamline__solscan_token_list_by_market_cap" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
dbt build -s "solana_models,tag:streamline_stake_accounts"
dbt run -s "solana_models,streamline__stake_program_accounts_2" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,9 @@ jobs:
run: |
dbt run -s "solana_models,streamline__validator_metadata_2" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,9 @@ jobs:
run: |
dbt run -s "solana_models,streamline__validator_vote_accounts_2" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,9 @@ jobs:
run: |
dbt run -s "solana_models,streamline__validator_vote_program_accounts_2" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,9 @@ jobs:
run: |
dbt run -s "solana_models,streamline__validators_list_2" --vars '{"STREAMLINE_INVOKE_STREAMS": True}'
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -1,46 +0,0 @@
name: dbt_run_transactions_backfill
run-name: dbt_run_transactions_backfill
on:
workflow_dispatch:
branches:
- "main"
env:
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:
group: ${{ github.workflow }}
jobs:
run_dbt_jobs:
runs-on: ubuntu-latest
environment:
name: workflow_prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ vars.PYTHON_VERSION }}"
cache: "pip"
- name: install dependencies
run: |
pip install -r requirements.txt
dbt deps
- name: Run DBT Jobs
run: |
dbt run -s "solana_models,tag:transactions_votes_with_non_votes_backfill"
dbt run -s "solana_models,tag:transactions_votes_with_non_votes_backfill"
dbt run -s "solana_models,tag:transactions_votes_with_non_votes_backfill"

View File

@ -1,45 +0,0 @@
name: dbt_run_transactions_units_consumed_backfill
run-name: dbt_run_transactions_units_consumed_backfill
on:
workflow_dispatch:
branches:
- "main"
env:
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"
concurrency:
group: ${{ github.workflow }}
jobs:
run_dbt_jobs:
runs-on: ubuntu-latest
environment:
name: workflow_prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ vars.PYTHON_VERSION }}"
cache: "pip"
- name: install dependencies
run: |
pip install -r requirements.txt
dbt deps
- name: Run DBT Jobs
run: |
dbt run -s "solana_models,tag:units_consumed_backfill"
dbt run -s "solana_models,tag:units_consumed_backfill"

View File

@ -43,3 +43,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt test -s "solana_models,./models" "solana_models,tag:test_daily" --exclude tag:test_weekly tag:test_hourly tag:exclude_test_daily
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -52,3 +52,10 @@ jobs:
if: success() || failure()
run: |
dbt run -s streamline__transactions_and_votes_missing_7_days
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run -m "solana_models,models/silver/_observability"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View File

@ -43,3 +43,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt test -s "solana_models,tag:test_weekly"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

27
.github/workflows/slack_notify.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Slack Notification
on:
workflow_call:
secrets:
SLACK_WEBHOOK_URL:
required: true
jobs:
notify:
runs-on: ubuntu-latest
environment: workflow_prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install requests
- name: Send Slack notification
run: python python/slack_alert.py
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

74
python/slack_alert.py Normal file
View File

@ -0,0 +1,74 @@
import requests
import os
import sys
def create_message():
"""Creates a simple failure notification message with repo, workflow name, and URL"""
# Get GitHub environment variables
repository = os.environ.get('GITHUB_REPOSITORY', 'Unknown repository')
repo_name = repository.split('/')[-1] if '/' in repository else repository
workflow_name = os.environ.get('GITHUB_WORKFLOW', 'Unknown workflow')
run_id = os.environ.get('GITHUB_RUN_ID', '')
server_url = os.environ.get('GITHUB_SERVER_URL', 'https://github.com')
# Build the workflow URL
workflow_url = f"{server_url}/{repository}/actions/runs/{run_id}"
message_body = {
"text": f"Failure in {repo_name}",
"attachments": [
{
"color": "#f44336", # Red color for failures
"fields": [
{
"title": "Repository",
"value": repository,
"short": True
},
{
"title": "Workflow",
"value": workflow_name,
"short": True
}
],
"actions": [
{
"type": "button",
"text": "View Workflow Run",
"style": "primary",
"url": workflow_url
}
],
"footer": "GitHub Actions"
}
]
}
return message_body
def send_alert(webhook_url):
"""Sends a failure notification to Slack"""
message = create_message()
try:
response = requests.post(webhook_url, json=message)
if response.status_code == 200:
print("Successfully sent Slack notification")
else:
print(f"Failed to send Slack notification: {response.status_code} {response.text}")
sys.exit(1)
except Exception as e:
print(f"Error sending Slack notification: {str(e)}")
sys.exit(1)
if __name__ == '__main__':
webhook_url = os.environ.get("SLACK_WEBHOOK_URL")
if not webhook_url:
print("ERROR: SLACK_WEBHOOK_URL environment variable is required")
sys.exit(1)
send_alert(webhook_url)