Skip to content

PythonBot - Workflow Failure Notifier #2300

PythonBot - Workflow Failure Notifier

PythonBot - Workflow Failure Notifier #2300

Workflow file for this run

name: PythonBot - Workflow Failure Notifier
on:
workflow_dispatch:
workflow_run:
workflows:
- "PR Formatting"
- "PR Changelog Check"
- "Hiero Solo Integration Tests"
- "Run Examples"
types:
- completed
permissions:
contents: read
pull-requests: write
concurrency:
group: "workflow-failure-${{ github.event.workflow_run.head_branch }}"
cancel-in-progress: true
jobs:
notify-pr:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Get associated PR number
id: get-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get branch from the workflow run
HEAD_BRANCH=$(gh run view ${{ github.event.workflow_run.id }} \
--repo ${{ github.repository }} \
--json headBranch --jq '.headBranch')
# Find the PR number for this branch
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state all --head "$HEAD_BRANCH" --json number --jq '.[0].number')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Comment on PR
if: env.PR_NUMBER != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO="${{ github.repository }}"
COMMENT=$(cat <<EOF
Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:
- [DCO signing guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/signing.md)
- [Changelog guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/changelog_entry.md)
- [Merge conflicts guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/merge_conflicts.md)
- [Rebase guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/rebasing.md)
- [Testing guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/testing.md)
- [Discord](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/discord.md)
- [Community Calls](https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week)
Thank you for contributing!
From the Hiero Python SDK Team
EOF
)
EXISTING_COMMENT=$(gh pr view "$PR_NUMBER" --repo "$REPO" --comments \
--json comments --jq ".comments[] | select(.body == \"${COMMENT//\"/\\\"}\") | .id")
if [ -z "$EXISTING_COMMENT" ]; then
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$COMMENT"
else
echo "Comment already exists, skipping."
fi