From e97673784ea4ea1efee3d42968bb4c5aa65719aa Mon Sep 17 00:00:00 2001 From: stktyagi Date: Fri, 6 Mar 2026 15:15:43 +0530 Subject: [PATCH 1/4] [fix] Fixed mentions via ci failure bot Fixed tagging both pr author and trigger author --- .github/workflows/bot-ci-failure.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bot-ci-failure.yml b/.github/workflows/bot-ci-failure.yml index e19b0731..d78210c9 100644 --- a/.github/workflows/bot-ci-failure.yml +++ b/.github/workflows/bot-ci-failure.yml @@ -21,6 +21,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'failure' }} outputs: pr_number: ${{ steps.pr.outputs.number }} + pr_author: ${{ steps.pr.outputs.author }} steps: - name: Find PR Number id: pr @@ -30,10 +31,17 @@ jobs: PR_NUMBER_PAYLOAD: ${{ github.event.workflow_run.pull_requests[0].number }} EVENT_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} run: | + emit_pr() { + local pr_number="$1" + local pr_author + pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login') + echo "number=$pr_number" >> "$GITHUB_OUTPUT" + echo "author=$pr_author" >> "$GITHUB_OUTPUT" + } PR_NUMBER="$PR_NUMBER_PAYLOAD" if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER from workflow payload." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi HEAD_SHA="$EVENT_HEAD_SHA" @@ -41,14 +49,14 @@ jobs: PR_NUMBER=$(gh api repos/$REPO/commits/$HEAD_SHA/pulls -q '.[0].number' 2>/dev/null || true) if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then echo "Found PR #$PR_NUMBER using Commits API." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi echo "API lookup failed/empty. Scanning open PRs for matching head SHA..." PR_NUMBER=$(gh pr list --repo "$REPO" --state open --limit 100 --json number,headRefOid --jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number" | head -n 1) if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER by scanning open PRs." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi echo "::warning::No open PR found. This workflow run might not be attached to an open PR." @@ -64,8 +72,8 @@ jobs: head_repo: ${{ github.event.workflow_run.head_repository.full_name }} base_repo: ${{ github.repository }} run_id: ${{ github.event.workflow_run.id }} - pr_author: ${{ github.event.workflow_run.actor.login }} - actor: ${{ github.actor }} + pr_author: ${{ needs.find-pr.outputs.pr_author }} + actor: ${{ github.event.workflow_run.actor.login }} secrets: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} APP_ID: ${{ secrets.OPENWISP_BOT_APP_ID }} From 8e9833aaf16ea7212687e17a6c807d9feb3c2764 Mon Sep 17 00:00:00 2001 From: stktyagi Date: Fri, 6 Mar 2026 15:46:06 +0530 Subject: [PATCH 2/4] [chores] Change ref to test Change ref for testing --- .github/workflows/reusable-bot-ci-failure.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-bot-ci-failure.yml b/.github/workflows/reusable-bot-ci-failure.yml index 40512399..f60d1339 100644 --- a/.github/workflows/reusable-bot-ci-failure.yml +++ b/.github/workflows/reusable-bot-ci-failure.yml @@ -51,7 +51,7 @@ jobs: uses: actions/checkout@v6 with: repository: openwisp/openwisp-utils - ref: master + ref: fix/fix-tagging-failure-bot path: trusted_scripts - name: Checkout PR Code From 8d00924ed801073d106821adeb32e22b937b4538 Mon Sep 17 00:00:00 2001 From: stktyagi Date: Fri, 6 Mar 2026 16:34:37 +0530 Subject: [PATCH 3/4] [chores] Testing on prev work Testing on previous implementation --- .github/workflows/bot-ci-failure.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/bot-ci-failure.yml b/.github/workflows/bot-ci-failure.yml index d78210c9..e19b0731 100644 --- a/.github/workflows/bot-ci-failure.yml +++ b/.github/workflows/bot-ci-failure.yml @@ -21,7 +21,6 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'failure' }} outputs: pr_number: ${{ steps.pr.outputs.number }} - pr_author: ${{ steps.pr.outputs.author }} steps: - name: Find PR Number id: pr @@ -31,17 +30,10 @@ jobs: PR_NUMBER_PAYLOAD: ${{ github.event.workflow_run.pull_requests[0].number }} EVENT_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} run: | - emit_pr() { - local pr_number="$1" - local pr_author - pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login') - echo "number=$pr_number" >> "$GITHUB_OUTPUT" - echo "author=$pr_author" >> "$GITHUB_OUTPUT" - } PR_NUMBER="$PR_NUMBER_PAYLOAD" if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER from workflow payload." - emit_pr "$PR_NUMBER" + echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT exit 0 fi HEAD_SHA="$EVENT_HEAD_SHA" @@ -49,14 +41,14 @@ jobs: PR_NUMBER=$(gh api repos/$REPO/commits/$HEAD_SHA/pulls -q '.[0].number' 2>/dev/null || true) if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then echo "Found PR #$PR_NUMBER using Commits API." - emit_pr "$PR_NUMBER" + echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT exit 0 fi echo "API lookup failed/empty. Scanning open PRs for matching head SHA..." PR_NUMBER=$(gh pr list --repo "$REPO" --state open --limit 100 --json number,headRefOid --jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number" | head -n 1) if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER by scanning open PRs." - emit_pr "$PR_NUMBER" + echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT exit 0 fi echo "::warning::No open PR found. This workflow run might not be attached to an open PR." @@ -72,8 +64,8 @@ jobs: head_repo: ${{ github.event.workflow_run.head_repository.full_name }} base_repo: ${{ github.repository }} run_id: ${{ github.event.workflow_run.id }} - pr_author: ${{ needs.find-pr.outputs.pr_author }} - actor: ${{ github.event.workflow_run.actor.login }} + pr_author: ${{ github.event.workflow_run.actor.login }} + actor: ${{ github.actor }} secrets: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} APP_ID: ${{ secrets.OPENWISP_BOT_APP_ID }} From 76d4afb7899c387f8a131d87b61a8bcec00984b4 Mon Sep 17 00:00:00 2001 From: stktyagi Date: Fri, 6 Mar 2026 17:04:15 +0530 Subject: [PATCH 4/4] [chores] Final version Fixed as final working versoin --- .github/workflows/bot-ci-failure.yml | 21 ++++++++++++++----- .github/workflows/reusable-bot-ci-failure.yml | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bot-ci-failure.yml b/.github/workflows/bot-ci-failure.yml index e19b0731..1d7e291d 100644 --- a/.github/workflows/bot-ci-failure.yml +++ b/.github/workflows/bot-ci-failure.yml @@ -21,6 +21,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'failure' }} outputs: pr_number: ${{ steps.pr.outputs.number }} + pr_author: ${{ steps.pr.outputs.author }} steps: - name: Find PR Number id: pr @@ -30,10 +31,20 @@ jobs: PR_NUMBER_PAYLOAD: ${{ github.event.workflow_run.pull_requests[0].number }} EVENT_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} run: | + emit_pr() { + local pr_number="$1" + local pr_author + pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login' 2>/dev/null || echo "") + if [ -z "$pr_author" ]; then + echo "::warning::Could not fetch PR author for PR #$pr_number" + fi + echo "number=$pr_number" >> "$GITHUB_OUTPUT" + echo "author=$pr_author" >> "$GITHUB_OUTPUT" + } PR_NUMBER="$PR_NUMBER_PAYLOAD" if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER from workflow payload." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi HEAD_SHA="$EVENT_HEAD_SHA" @@ -41,14 +52,14 @@ jobs: PR_NUMBER=$(gh api repos/$REPO/commits/$HEAD_SHA/pulls -q '.[0].number' 2>/dev/null || true) if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then echo "Found PR #$PR_NUMBER using Commits API." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi echo "API lookup failed/empty. Scanning open PRs for matching head SHA..." PR_NUMBER=$(gh pr list --repo "$REPO" --state open --limit 100 --json number,headRefOid --jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number" | head -n 1) if [ -n "$PR_NUMBER" ]; then echo "Found PR #$PR_NUMBER by scanning open PRs." - echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT + emit_pr "$PR_NUMBER" exit 0 fi echo "::warning::No open PR found. This workflow run might not be attached to an open PR." @@ -64,8 +75,8 @@ jobs: head_repo: ${{ github.event.workflow_run.head_repository.full_name }} base_repo: ${{ github.repository }} run_id: ${{ github.event.workflow_run.id }} - pr_author: ${{ github.event.workflow_run.actor.login }} - actor: ${{ github.actor }} + pr_author: ${{ needs.find-pr.outputs.pr_author }} + actor: ${{ github.event.workflow_run.actor.login }} secrets: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} APP_ID: ${{ secrets.OPENWISP_BOT_APP_ID }} diff --git a/.github/workflows/reusable-bot-ci-failure.yml b/.github/workflows/reusable-bot-ci-failure.yml index f60d1339..40512399 100644 --- a/.github/workflows/reusable-bot-ci-failure.yml +++ b/.github/workflows/reusable-bot-ci-failure.yml @@ -51,7 +51,7 @@ jobs: uses: actions/checkout@v6 with: repository: openwisp/openwisp-utils - ref: fix/fix-tagging-failure-bot + ref: master path: trusted_scripts - name: Checkout PR Code