Skip to content

Commit adc49e5

Browse files
committed
fix: address CodeRabbit review feedback for verified-commits workflow
- Update actions/checkout to v4.3.1 (from v4.2.2) - Add pr_number input for workflow_dispatch support - Fix concurrency group to handle manual triggers - Enrich logs with repository, PR number, actor context - Update JS to prefer PR_NUMBER env var for workflow_dispatch Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
1 parent 590cf16 commit adc49e5

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/scripts/bot-verified-commits.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ async function postVerificationComment(
247247
async function main({ github, context }) {
248248
const owner = sanitizeString(context.repo?.owner);
249249
const repo = sanitizeString(context.repo?.repo);
250-
const prNumber = validatePRNumber(context.payload?.pull_request?.number);
250+
// Support PR_NUMBER env var for workflow_dispatch, fallback to context payload
251+
const prNumber = validatePRNumber(
252+
process.env.PR_NUMBER || context.payload?.pull_request?.number
253+
);
251254
const repoPattern = /^[A-Za-z0-9_.-]+$/;
252255

253256
// Validate repo context

.github/workflows/bot-verified-commits.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
types: [opened, synchronize]
1616
workflow_dispatch:
1717
inputs:
18+
pr_number:
19+
description: "PR number to verify (required for manual runs)"
20+
required: true
1821
dry_run:
1922
description: "Run without posting comments"
2023
required: false
@@ -26,7 +29,7 @@ permissions:
2629
issues: write
2730

2831
concurrency:
29-
group: "verify-commits-${{ github.event.pull_request.number }}"
32+
group: "verify-commits-${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}"
3033
cancel-in-progress: true
3134

3235
jobs:
@@ -55,25 +58,34 @@ jobs:
5558
# Dry-run mode (workflow_dispatch uses input, PR events default to false)
5659
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || 'false' }}
5760

61+
# PR number (supports both PR events and manual workflow_dispatch)
62+
PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}
63+
5864
steps:
5965
- name: Harden the runner (Audit all outbound calls)
6066
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
6167
with:
6268
egress-policy: audit
6369

6470
- name: Checkout repository
65-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
uses: actions/checkout@538c8244bb4f6864465593836f6d2f3c75460a56 # v4.3.1
6672
with:
6773
sparse-checkout: .github/scripts
6874
persist-credentials: false
6975

70-
- name: Log dry-run status
76+
- name: Log workflow context
7177
run: |
78+
echo "Repository: ${{ github.repository }}"
79+
echo "PR: ${{ env.PR_NUMBER }}"
80+
echo "Actor: ${{ github.actor }}"
81+
echo "Event: ${{ github.event_name }}"
7282
echo "Dry run mode: ${{ env.DRY_RUN }}"
7383
7484
- name: Verify PR commits
7585
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
7686
id: verify
87+
env:
88+
PR_NUMBER: ${{ env.PR_NUMBER }}
7789
with:
7890
github-token: ${{ secrets.GITHUB_TOKEN }}
7991
result-encoding: json
@@ -91,6 +103,7 @@ jobs:
91103
if: steps.verify.outputs.success != 'true' && env.DRY_RUN != 'true'
92104
run: |
93105
echo "❌ Pull request has unverified commits."
106+
echo "Unverified commits: ${{ steps.verify.outputs.unverified_count }}"
94107
echo "Please sign your commits with GPG."
95108
echo "See: ${{ env.SIGNING_GUIDE_URL }}"
96109
exit 1

0 commit comments

Comments
 (0)