From 6c43cb1287e1a6c39c8f026a205069c6c63dd50e Mon Sep 17 00:00:00 2001 From: Fabrizio Ferri Benedetti Date: Mon, 27 Jul 2026 10:06:10 +0200 Subject: [PATCH] Fix docs-review noop when called via workflow_call from pr-ai-menu When the lock file is called via uses: from docs-pr-ai-menu, the $GITHUB_EVENT_PATH on disk contains the workflow_call payload (just inputs), not the original issue_comment event. The jq that extracts the PR number from GITHUB_EVENT_PATH returns empty, causing the pre-step to write "not a pull request context" and the agent to noop. GitHub Actions expressions (${{ github.event.* }}) DO propagate the original event context to called workflows, so injecting the PR number via env: before the jq fallback fixes the extraction without requiring a new input. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/gh-aw-docs-review.lock.yml | 29 ++++++++++++-------- .github/workflows/gh-aw-docs-review.md | 14 ++++++++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/gh-aw-docs-review.lock.yml b/.github/workflows/gh-aw-docs-review.lock.yml index 25974e0..1dc6896 100644 --- a/.github/workflows/gh-aw-docs-review.lock.yml +++ b/.github/workflows/gh-aw-docs-review.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"5b4ec0cabbf28f8249e0f955ad94c47ad4ad34522533746f44d989227829c424","body_hash":"d89dfffe8883f5069cfdc240804088c09e1878a40ce71142a7d3a0b3839b211d","compiler_version":"v0.83.1","agent_id":"copilot","agent_model":"claude-sonnet-5","engine_versions":{"copilot":"1.0.73"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"dcd02f6c2b28b83fd7645d441e7c48ecbf19000486a79e0e0e614662b14ee659","body_hash":"ea6d193a9cf22fe34ba9080df5261e628357e2c73114c31bbd42515aa9a61479","compiler_version":"v0.83.1","agent_id":"copilot","agent_model":"claude-sonnet-5","engine_versions":{"copilot":"1.0.73"}} # gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_PLUGINS_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0","version":"v7.0.0"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"373c709c69115d41ff229c7e5df9f8788daa9553","version":"v9"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"820762786026740c76f36085b0efc47a31fe5020","version":"v7.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"8bdba8075360648fe6802302a5b4e016361dc6ac","version":"v0.83.1"},{"repo":"microsoft/apm-action","sha":"b48dd081eb0050f6d7f32d0e7caa0a59a2d419fd","version":"v1.7.2"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.38","digest":"sha256:cb928eb62d9139a013c2d278dab19af232d35a2d83dca71a3d98eb431f786243","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.27.38@sha256:cb928eb62d9139a013c2d278dab19af232d35a2d83dca71a3d98eb431f786243"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.38","digest":"sha256:cd6145620d96acee46e1ede25180a13aa36002467e663db0caa453a8bc8eb60c","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.38@sha256:cd6145620d96acee46e1ede25180a13aa36002467e663db0caa453a8bc8eb60c"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.38","digest":"sha256:6c19094d95aad5f9f128ad5e583f0f2b894b158aa66c3b86dd9bcc90970a2917","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.27.38@sha256:6c19094d95aad5f9f128ad5e583f0f2b894b158aa66c3b86dd9bcc90970a2917"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.3","digest":"sha256:3c744710ea275cd5ee65db92a1099e0d980754bd9fafda9ce67704c67004dc83","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.3@sha256:3c744710ea275cd5ee65db92a1099e0d980754bd9fafda9ce67704c67004dc83"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b","pinned_image":"ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b"},{"image":"ghcr.io/github/github-mcp-server:v1.6.0","digest":"sha256:2b0c48b070f61e9d3969269ead600f62d00fb237b60ac849ef3d166ee7de9ad3","pinned_image":"ghcr.io/github/github-mcp-server:v1.6.0@sha256:2b0c48b070f61e9d3969269ead600f62d00fb237b60ac849ef3d166ee7de9ad3"}]} # This file was automatically generated by gh-aw (v0.83.1). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -307,20 +307,20 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_c12eba461906a4f0_EOF' + cat << 'GH_AW_PROMPT_52eb7a45073d99df_EOF' - GH_AW_PROMPT_c12eba461906a4f0_EOF + GH_AW_PROMPT_52eb7a45073d99df_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_c12eba461906a4f0_EOF' + cat << 'GH_AW_PROMPT_52eb7a45073d99df_EOF' Tools: add_comment, create_pull_request_review_comment(max:20), submit_pull_request_review, missing_tool, missing_data, noop - GH_AW_PROMPT_c12eba461906a4f0_EOF + GH_AW_PROMPT_52eb7a45073d99df_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_c12eba461906a4f0_EOF' + cat << 'GH_AW_PROMPT_52eb7a45073d99df_EOF' The following GitHub context information is available for this workflow: {{#if github.actor}} @@ -349,9 +349,9 @@ jobs: {{/if}} - GH_AW_PROMPT_c12eba461906a4f0_EOF + GH_AW_PROMPT_52eb7a45073d99df_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_c12eba461906a4f0_EOF' + cat << 'GH_AW_PROMPT_52eb7a45073d99df_EOF' ## Formatting Guidelines @@ -423,7 +423,7 @@ jobs: When the workflow runs: - - Confirm that the triggering item is a pull request or a PR comment context. If this is not a PR context, call `noop` with a short explanation. + - Read `/tmp/gh-aw/docs-review-data/trigger-context.json` first. If `is_pr_context` is `false`, call `noop`. If `is_pr_context` is `true`, proceed — `pr_number` contains the resolved PR number. Do not use the `pull-request-number` context variable to gate this check: for `issue_comment` triggers (e.g., the AI PR menu), `pull-request-number` is always null even on real PRs. - Validate `inputs.review-scope`. If it is not `docs-subtree` or `repo-wide-markdown`, call `noop` with a short explanation. - Review only files that both changed in the PR and match the configured review scope. - Ignore every other changed file outside the configured review scope. @@ -719,7 +719,7 @@ jobs: __GH_AW_EXPR_49B959F1__ - GH_AW_PROMPT_c12eba461906a4f0_EOF + GH_AW_PROMPT_52eb7a45073d99df_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -973,14 +973,20 @@ jobs: set -euo pipefail mkdir -p /tmp/gh-aw/docs-review-data/scope - PR_NUMBER=$(jq -r 'if .pull_request then .pull_request.number elif .issue.pull_request then .issue.number else empty end' "$GITHUB_EVENT_PATH") + PR_NUMBER="$PR_NUMBER_FROM_CONTEXT" + if [ -z "$PR_NUMBER" ]; then + PR_NUMBER=$(jq -r 'if .pull_request then .pull_request.number elif .issue.pull_request then .issue.number else empty end' "$GITHUB_EVENT_PATH") + fi if [ -z "$PR_NUMBER" ]; then : > /tmp/gh-aw/docs-review-data/eligible-files.txt echo '{}' > /tmp/gh-aw/docs-review-data/vale.json echo '{"finding_count":0,"file_count":0,"eligible_count":0,"vale_exit":0,"skipped":"not a pull request context"}' > /tmp/gh-aw/docs-review-data/vale-stats.json + echo '{"pr_number":null,"is_pr_context":false}' > /tmp/gh-aw/docs-review-data/trigger-context.json exit 0 fi + echo "{\"pr_number\":$PR_NUMBER,\"is_pr_context\":true}" > /tmp/gh-aw/docs-review-data/trigger-context.json + if [ "$REVIEW_SCOPE" != "docs-subtree" ] && [ "$REVIEW_SCOPE" != "repo-wide-markdown" ]; then : > /tmp/gh-aw/docs-review-data/eligible-files.txt echo '{}' > /tmp/gh-aw/docs-review-data/vale.json @@ -1048,6 +1054,7 @@ jobs: GITHUB_API_URL: https://localhost:18443/api/v3 GITHUB_GRAPHQL_URL: https://localhost:18443/api/graphql NODE_EXTRA_CA_CERTS: /tmp/gh-aw/proxy-logs/proxy-tls/ca.crt + PR_NUMBER_FROM_CONTEXT: ${{ github.event.pull_request.number || github.event.issue.number }} REVIEW_SCOPE: ${{ inputs.review-scope }} - name: Configure Git credentials env: diff --git a/.github/workflows/gh-aw-docs-review.md b/.github/workflows/gh-aw-docs-review.md index 93b7f15..1471afa 100644 --- a/.github/workflows/gh-aw-docs-review.md +++ b/.github/workflows/gh-aw-docs-review.md @@ -113,18 +113,28 @@ steps: env: GH_TOKEN: ${{ github.token }} REVIEW_SCOPE: ${{ inputs.review-scope }} + # Expressions propagate the original event context even through workflow_call; + # $GITHUB_EVENT_PATH on disk only has the workflow_call payload when called + # via uses:, so we pass the PR number via env to avoid the jq returning empty. + PR_NUMBER_FROM_CONTEXT: ${{ github.event.pull_request.number || github.event.issue.number }} run: | set -euo pipefail mkdir -p /tmp/gh-aw/docs-review-data/scope - PR_NUMBER=$(jq -r 'if .pull_request then .pull_request.number elif .issue.pull_request then .issue.number else empty end' "$GITHUB_EVENT_PATH") + PR_NUMBER="$PR_NUMBER_FROM_CONTEXT" + if [ -z "$PR_NUMBER" ]; then + PR_NUMBER=$(jq -r 'if .pull_request then .pull_request.number elif .issue.pull_request then .issue.number else empty end' "$GITHUB_EVENT_PATH") + fi if [ -z "$PR_NUMBER" ]; then : > /tmp/gh-aw/docs-review-data/eligible-files.txt echo '{}' > /tmp/gh-aw/docs-review-data/vale.json echo '{"finding_count":0,"file_count":0,"eligible_count":0,"vale_exit":0,"skipped":"not a pull request context"}' > /tmp/gh-aw/docs-review-data/vale-stats.json + echo '{"pr_number":null,"is_pr_context":false}' > /tmp/gh-aw/docs-review-data/trigger-context.json exit 0 fi + echo "{\"pr_number\":$PR_NUMBER,\"is_pr_context\":true}" > /tmp/gh-aw/docs-review-data/trigger-context.json + if [ "$REVIEW_SCOPE" != "docs-subtree" ] && [ "$REVIEW_SCOPE" != "repo-wide-markdown" ]; then : > /tmp/gh-aw/docs-review-data/eligible-files.txt echo '{}' > /tmp/gh-aw/docs-review-data/vale.json @@ -218,7 +228,7 @@ Configured review scope for this run: `${{ inputs.review-scope }}`. When the workflow runs: -- Confirm that the triggering item is a pull request or a PR comment context. If this is not a PR context, call `noop` with a short explanation. +- Read `/tmp/gh-aw/docs-review-data/trigger-context.json` first. If `is_pr_context` is `false`, call `noop`. If `is_pr_context` is `true`, proceed — `pr_number` contains the resolved PR number. Do not use the `pull-request-number` context variable to gate this check: for `issue_comment` triggers (e.g., the AI PR menu), `pull-request-number` is always null even on real PRs. - Validate `inputs.review-scope`. If it is not `docs-subtree` or `repo-wide-markdown`, call `noop` with a short explanation. - Review only files that both changed in the PR and match the configured review scope. - Ignore every other changed file outside the configured review scope.