Skip to content

PythonBot - Workflow Failure Notifier #123

PythonBot - Workflow Failure Notifier

PythonBot - Workflow Failure Notifier #123

Workflow file for this run

name: PythonBot - Workflow Failure Notifier
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Run in dry-run mode (no PR comment posting)'
type: boolean
default: true
failed_run_id:
description: 'Failed workflow run ID for testing (optional)'
required: false
workflow_run:
workflows:
- "PR Formatting"
- "PR Changelog Check"
- "Hiero Solo Integration & Unit Tests"
- "Run Examples"
types:
- completed
permissions:
contents: read
pull-requests: read
issues: write
concurrency:
group: "workflow-failure-${{ github.event.workflow_run.head_branch || github.run_id }}"
cancel-in-progress: true
jobs:
notify-pr:
if: ${{ github.event.workflow_run.conclusion == 'failure' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
env:
# Behaviour:
# - workflow_run: DRY_RUN = 0 (real actions)
# - workflow_dispatch: DRY_RUN derived from the "dry_run" input
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.dry_run == 'true' && '1' || '0') || '0' }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '20'
- name: Notify PR of workflow failure
if: github.event_name != 'workflow_dispatch' || github.event.inputs.failed_run_id != ''
env:
FAILED_WORKFLOW_NAME: ${{ github.event.workflow_run.name || 'Manual Test Run' }}
FAILED_RUN_ID: ${{ github.event.inputs.failed_run_id || github.event.workflow_run.id }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
DRY_RUN: ${{ env.DRY_RUN }}
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number || '' }}
run: node .github/scripts/bot-workflows.js