pr-review-intent.lock.yml 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. # gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"becc5fed9e22fd07d745f90ba113bf84ee1cb0fc0bbf5b96af9cfc43c0545de2","compiler_version":"v0.68.3","strict":true,"agent_id":"claude","agent_model":"MiniMax-M2.7"}
  2. # gh-aw-manifest: {"version":1,"secrets":["GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN","MINIMAX_API_KEY"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"373c709c69115d41ff229c7e5df9f8788daa9553","version":"v9"},{"repo":"actions/setup-node","sha":"53b83947a5a98c8d113130e565377fae1a50d02f","version":"v6.3.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"ba90f2186d7ad780ec640f364005fa24e797b360","version":"v0.68.3"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.20"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.20"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.2.19"},{"image":"ghcr.io/github/github-mcp-server:v0.32.0"},{"image":"node:lts-alpine"}]}
  3. # ___ _ _
  4. # / _ \ | | (_)
  5. # | |_| | __ _ ___ _ __ | |_ _ ___
  6. # | _ |/ _` |/ _ \ '_ \| __| |/ __|
  7. # | | | | (_| | __/ | | | |_| | (__
  8. # \_| |_/\__, |\___|_| |_|\__|_|\___|
  9. # __/ |
  10. # _ _ |___/
  11. # | | | | / _| |
  12. # | | | | ___ _ __ _ __| |_| | _____ ____
  13. # | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___|
  14. # \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \
  15. # \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/
  16. #
  17. # This file was automatically generated by gh-aw (v0.68.3). DO NOT EDIT.
  18. #
  19. # To update this file, edit the corresponding .md file and run:
  20. # gh aw compile
  21. # Not all edits will cause changes to this file.
  22. #
  23. # For more information: https://github.github.com/gh-aw/introduction/overview/
  24. #
  25. # 自动审计 Pull Request 的代码意图、隐含约束、实现对齐情况与发布风险
  26. #
  27. # Resolved workflow manifest:
  28. # Imports:
  29. # - shared/engine.md
  30. # - shared/network.md
  31. #
  32. # Secrets used:
  33. # - GH_AW_GITHUB_MCP_SERVER_TOKEN
  34. # - GH_AW_GITHUB_TOKEN
  35. # - GITHUB_TOKEN
  36. # - MINIMAX_API_KEY
  37. #
  38. # Custom actions used:
  39. # - actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  40. # - actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  41. # - actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  42. # - actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
  43. # - actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  44. # - github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  45. #
  46. # Container images used:
  47. # - ghcr.io/github/gh-aw-firewall/agent:0.25.20
  48. # - ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20
  49. # - ghcr.io/github/gh-aw-firewall/squid:0.25.20
  50. # - ghcr.io/github/gh-aw-mcpg:v0.2.19
  51. # - ghcr.io/github/github-mcp-server:v0.32.0
  52. # - node:lts-alpine
  53. name: "PR Review Intent"
  54. "on":
  55. pull_request_target:
  56. branches:
  57. - dev
  58. types:
  59. - opened
  60. - reopened
  61. permissions: {}
  62. concurrency:
  63. group: "gh-aw-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}"
  64. cancel-in-progress: true
  65. run-name: "PR Review Intent"
  66. jobs:
  67. activation:
  68. needs: pre_activation
  69. if: needs.pre_activation.outputs.activated == 'true'
  70. runs-on: ubuntu-slim
  71. permissions:
  72. actions: read
  73. contents: read
  74. outputs:
  75. body: ${{ steps.sanitized.outputs.body }}
  76. comment_id: ""
  77. comment_repo: ""
  78. lockdown_check_failed: ${{ steps.generate_aw_info.outputs.lockdown_check_failed == 'true' }}
  79. model: ${{ steps.generate_aw_info.outputs.model }}
  80. secret_verification_result: ${{ steps.validate-secret.outputs.verification_result }}
  81. setup-trace-id: ${{ steps.setup.outputs.trace-id }}
  82. stale_lock_file_failed: ${{ steps.check-lock-file.outputs.stale_lock_file_failed == 'true' }}
  83. text: ${{ steps.sanitized.outputs.text }}
  84. title: ${{ steps.sanitized.outputs.title }}
  85. steps:
  86. - name: Setup Scripts
  87. id: setup
  88. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  89. with:
  90. destination: ${{ runner.temp }}/gh-aw/actions
  91. job-name: ${{ github.job }}
  92. trace-id: ${{ needs.pre_activation.outputs.setup-trace-id }}
  93. - name: Generate agentic run info
  94. id: generate_aw_info
  95. env:
  96. GH_AW_INFO_ENGINE_ID: "claude"
  97. GH_AW_INFO_ENGINE_NAME: "Claude Code"
  98. GH_AW_INFO_MODEL: "MiniMax-M2.7"
  99. GH_AW_INFO_VERSION: "2.1.98"
  100. GH_AW_INFO_AGENT_VERSION: "2.1.98"
  101. GH_AW_INFO_CLI_VERSION: "v0.68.3"
  102. GH_AW_INFO_WORKFLOW_NAME: "PR Review Intent"
  103. GH_AW_INFO_EXPERIMENTAL: "false"
  104. GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true"
  105. GH_AW_INFO_STAGED: "false"
  106. GH_AW_INFO_ALLOWED_DOMAINS: '["api-inference.modelscope.cn","api.minimaxi.com","defaults","open.bigmodel.cn"]'
  107. GH_AW_INFO_FIREWALL_ENABLED: "true"
  108. GH_AW_INFO_AWF_VERSION: "v0.25.20"
  109. GH_AW_INFO_AWMG_VERSION: ""
  110. GH_AW_INFO_FIREWALL_TYPE: "squid"
  111. GH_AW_COMPILED_STRICT: "true"
  112. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  113. with:
  114. script: |
  115. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  116. setupGlobals(core, github, context, exec, io, getOctokit);
  117. const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_aw_info.cjs');
  118. await main(core, context);
  119. - name: Validate ANTHROPIC_API_KEY secret
  120. id: validate-secret
  121. run: bash "${RUNNER_TEMP}/gh-aw/actions/validate_multi_secret.sh" ANTHROPIC_API_KEY 'Claude Code' https://github.github.com/gh-aw/reference/engines/#anthropic-claude-code
  122. env:
  123. ANTHROPIC_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
  124. - name: Checkout .github and .agents folders
  125. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  126. with:
  127. persist-credentials: false
  128. sparse-checkout: |
  129. .github
  130. .agents
  131. sparse-checkout-cone-mode: true
  132. fetch-depth: 1
  133. - name: Check workflow lock file
  134. id: check-lock-file
  135. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  136. env:
  137. GH_AW_WORKFLOW_FILE: "pr-review-intent.lock.yml"
  138. GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}"
  139. with:
  140. script: |
  141. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  142. setupGlobals(core, github, context, exec, io, getOctokit);
  143. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_workflow_timestamp_api.cjs');
  144. await main();
  145. - name: Check compile-agentic version
  146. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  147. env:
  148. GH_AW_COMPILED_VERSION: "v0.68.3"
  149. with:
  150. script: |
  151. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  152. setupGlobals(core, github, context, exec, io, getOctokit);
  153. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_version_updates.cjs');
  154. await main();
  155. - name: Compute current body text
  156. id: sanitized
  157. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  158. with:
  159. script: |
  160. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  161. setupGlobals(core, github, context, exec, io, getOctokit);
  162. const { main } = require('${{ runner.temp }}/gh-aw/actions/compute_text.cjs');
  163. await main();
  164. - name: Create prompt with built-in context
  165. env:
  166. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  167. GH_AW_SAFE_OUTPUTS: ${{ runner.temp }}/gh-aw/safeoutputs/outputs.jsonl
  168. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  169. GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }}
  170. GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }}
  171. GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
  172. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  173. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  174. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  175. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  176. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  177. GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
  178. GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
  179. # poutine:ignore untrusted_checkout_exec
  180. run: |
  181. bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh"
  182. {
  183. cat << 'GH_AW_PROMPT_a147d06b37f19aa5_EOF'
  184. <system>
  185. GH_AW_PROMPT_a147d06b37f19aa5_EOF
  186. cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md"
  187. cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md"
  188. cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md"
  189. cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md"
  190. cat << 'GH_AW_PROMPT_a147d06b37f19aa5_EOF'
  191. <safe-output-tools>
  192. Tools: add_comment, missing_tool, missing_data, noop
  193. </safe-output-tools>
  194. <github-context>
  195. The following GitHub context information is available for this workflow:
  196. {{#if __GH_AW_GITHUB_ACTOR__ }}
  197. - **actor**: __GH_AW_GITHUB_ACTOR__
  198. {{/if}}
  199. {{#if __GH_AW_GITHUB_REPOSITORY__ }}
  200. - **repository**: __GH_AW_GITHUB_REPOSITORY__
  201. {{/if}}
  202. {{#if __GH_AW_GITHUB_WORKSPACE__ }}
  203. - **workspace**: __GH_AW_GITHUB_WORKSPACE__
  204. {{/if}}
  205. {{#if __GH_AW_GITHUB_EVENT_ISSUE_NUMBER__ }}
  206. - **issue-number**: #__GH_AW_GITHUB_EVENT_ISSUE_NUMBER__
  207. {{/if}}
  208. {{#if __GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__ }}
  209. - **discussion-number**: #__GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__
  210. {{/if}}
  211. {{#if __GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__ }}
  212. - **pull-request-number**: #__GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__
  213. {{/if}}
  214. {{#if __GH_AW_GITHUB_EVENT_COMMENT_ID__ }}
  215. - **comment-id**: __GH_AW_GITHUB_EVENT_COMMENT_ID__
  216. {{/if}}
  217. {{#if __GH_AW_GITHUB_RUN_ID__ }}
  218. - **workflow-run-id**: __GH_AW_GITHUB_RUN_ID__
  219. {{/if}}
  220. </github-context>
  221. GH_AW_PROMPT_a147d06b37f19aa5_EOF
  222. cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md"
  223. cat << 'GH_AW_PROMPT_a147d06b37f19aa5_EOF'
  224. </system>
  225. {{#runtime-import .github/workflows/shared/engine.md}}
  226. {{#runtime-import .github/workflows/shared/network.md}}
  227. {{#runtime-import .github/workflows/pr-review-intent.md}}
  228. GH_AW_PROMPT_a147d06b37f19aa5_EOF
  229. } > "$GH_AW_PROMPT"
  230. - name: Interpolate variables and render templates
  231. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  232. env:
  233. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  234. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  235. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  236. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  237. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  238. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  239. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  240. with:
  241. script: |
  242. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  243. setupGlobals(core, github, context, exec, io, getOctokit);
  244. const { main } = require('${{ runner.temp }}/gh-aw/actions/interpolate_prompt.cjs');
  245. await main();
  246. - name: Substitute placeholders
  247. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  248. env:
  249. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  250. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  251. GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }}
  252. GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }}
  253. GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
  254. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  255. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  256. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  257. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  258. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  259. GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
  260. GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
  261. GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: ${{ needs.pre_activation.outputs.activated }}
  262. with:
  263. script: |
  264. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  265. setupGlobals(core, github, context, exec, io, getOctokit);
  266. const substitutePlaceholders = require('${{ runner.temp }}/gh-aw/actions/substitute_placeholders.cjs');
  267. // Call the substitution function
  268. return await substitutePlaceholders({
  269. file: process.env.GH_AW_PROMPT,
  270. substitutions: {
  271. GH_AW_GITHUB_ACTOR: process.env.GH_AW_GITHUB_ACTOR,
  272. GH_AW_GITHUB_EVENT_COMMENT_ID: process.env.GH_AW_GITHUB_EVENT_COMMENT_ID,
  273. GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: process.env.GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER,
  274. GH_AW_GITHUB_EVENT_ISSUE_NUMBER: process.env.GH_AW_GITHUB_EVENT_ISSUE_NUMBER,
  275. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA,
  276. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA,
  277. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER,
  278. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE,
  279. GH_AW_GITHUB_REPOSITORY: process.env.GH_AW_GITHUB_REPOSITORY,
  280. GH_AW_GITHUB_RUN_ID: process.env.GH_AW_GITHUB_RUN_ID,
  281. GH_AW_GITHUB_WORKSPACE: process.env.GH_AW_GITHUB_WORKSPACE,
  282. GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED
  283. }
  284. });
  285. - name: Validate prompt placeholders
  286. env:
  287. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  288. # poutine:ignore untrusted_checkout_exec
  289. run: bash "${RUNNER_TEMP}/gh-aw/actions/validate_prompt_placeholders.sh"
  290. - name: Print prompt
  291. env:
  292. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  293. # poutine:ignore untrusted_checkout_exec
  294. run: bash "${RUNNER_TEMP}/gh-aw/actions/print_prompt_summary.sh"
  295. - name: Upload activation artifact
  296. if: success()
  297. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  298. with:
  299. name: activation
  300. path: |
  301. /tmp/gh-aw/aw_info.json
  302. /tmp/gh-aw/aw-prompts/prompt.txt
  303. /tmp/gh-aw/github_rate_limits.jsonl
  304. if-no-files-found: ignore
  305. retention-days: 1
  306. agent:
  307. needs: activation
  308. runs-on: ubuntu-latest
  309. permissions:
  310. checks: read
  311. contents: read
  312. issues: read
  313. pull-requests: read
  314. statuses: read
  315. env:
  316. DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
  317. GH_AW_ASSETS_ALLOWED_EXTS: ""
  318. GH_AW_ASSETS_BRANCH: ""
  319. GH_AW_ASSETS_MAX_SIZE_KB: 0
  320. GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs
  321. GH_AW_WORKFLOW_ID_SANITIZED: prreviewintent
  322. outputs:
  323. checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }}
  324. effective_tokens: ${{ steps.parse-mcp-gateway.outputs.effective_tokens }}
  325. has_patch: ${{ steps.collect_output.outputs.has_patch }}
  326. model: ${{ needs.activation.outputs.model }}
  327. output: ${{ steps.collect_output.outputs.output }}
  328. output_types: ${{ steps.collect_output.outputs.output_types }}
  329. setup-trace-id: ${{ steps.setup.outputs.trace-id }}
  330. steps:
  331. - name: Setup Scripts
  332. id: setup
  333. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  334. with:
  335. destination: ${{ runner.temp }}/gh-aw/actions
  336. job-name: ${{ github.job }}
  337. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  338. - name: Set runtime paths
  339. id: set-runtime-paths
  340. run: |
  341. {
  342. echo "GH_AW_SAFE_OUTPUTS=${RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl"
  343. echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json"
  344. echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json"
  345. } >> "$GITHUB_OUTPUT"
  346. - name: Checkout repository
  347. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  348. with:
  349. persist-credentials: false
  350. - name: Create gh-aw temp directory
  351. run: bash "${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh"
  352. - name: Configure gh CLI for GitHub Enterprise
  353. run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh"
  354. env:
  355. GH_TOKEN: ${{ github.token }}
  356. - name: Configure Git credentials
  357. env:
  358. REPO_NAME: ${{ github.repository }}
  359. SERVER_URL: ${{ github.server_url }}
  360. GITHUB_TOKEN: ${{ github.token }}
  361. run: |
  362. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  363. git config --global user.name "github-actions[bot]"
  364. git config --global am.keepcr true
  365. # Re-authenticate git with GitHub token
  366. SERVER_URL_STRIPPED="${SERVER_URL#https://}"
  367. git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
  368. echo "Git configured with standard GitHub Actions identity"
  369. - name: Checkout PR branch
  370. id: checkout-pr
  371. if: |
  372. github.event.pull_request || github.event.issue.pull_request
  373. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  374. env:
  375. GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  376. with:
  377. github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  378. script: |
  379. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  380. setupGlobals(core, github, context, exec, io, getOctokit);
  381. const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs');
  382. await main();
  383. - name: Setup Node.js
  384. uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
  385. with:
  386. node-version: '24'
  387. package-manager-cache: false
  388. - name: Install AWF binary
  389. run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.25.20
  390. - name: Install Claude Code CLI
  391. run: npm install --ignore-scripts -g @anthropic-ai/claude-code@2.1.98
  392. - name: Parse integrity filter lists
  393. id: parse-guard-vars
  394. env:
  395. GH_AW_BLOCKED_USERS_VAR: ${{ vars.GH_AW_GITHUB_BLOCKED_USERS || '' }}
  396. GH_AW_TRUSTED_USERS_VAR: ${{ vars.GH_AW_GITHUB_TRUSTED_USERS || '' }}
  397. GH_AW_APPROVAL_LABELS_VAR: ${{ vars.GH_AW_GITHUB_APPROVAL_LABELS || '' }}
  398. run: bash "${RUNNER_TEMP}/gh-aw/actions/parse_guard_list.sh"
  399. - name: Download container images
  400. run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.25.20 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20 ghcr.io/github/gh-aw-firewall/squid:0.25.20 ghcr.io/github/gh-aw-mcpg:v0.2.19 ghcr.io/github/github-mcp-server:v0.32.0 node:lts-alpine
  401. - name: Write Safe Outputs Config
  402. run: |
  403. mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
  404. mkdir -p /tmp/gh-aw/safeoutputs
  405. mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
  406. cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_cfb86eaf8debc52f_EOF'
  407. {"add_comment":{"max":1,"target":"triggering"},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"report_incomplete":{}}
  408. GH_AW_SAFE_OUTPUTS_CONFIG_cfb86eaf8debc52f_EOF
  409. - name: Write Safe Outputs Tools
  410. env:
  411. GH_AW_TOOLS_META_JSON: |
  412. {
  413. "description_suffixes": {
  414. "add_comment": " CONSTRAINTS: Maximum 1 comment(s) can be added. Target: triggering. Supports reply_to_id for discussion threading."
  415. },
  416. "repo_params": {},
  417. "dynamic_tools": []
  418. }
  419. GH_AW_VALIDATION_JSON: |
  420. {
  421. "add_comment": {
  422. "defaultMax": 1,
  423. "fields": {
  424. "body": {
  425. "required": true,
  426. "type": "string",
  427. "sanitize": true,
  428. "maxLength": 65000
  429. },
  430. "item_number": {
  431. "issueOrPRNumber": true
  432. },
  433. "reply_to_id": {
  434. "type": "string",
  435. "maxLength": 256
  436. },
  437. "repo": {
  438. "type": "string",
  439. "maxLength": 256
  440. }
  441. }
  442. },
  443. "missing_data": {
  444. "defaultMax": 20,
  445. "fields": {
  446. "alternatives": {
  447. "type": "string",
  448. "sanitize": true,
  449. "maxLength": 256
  450. },
  451. "context": {
  452. "type": "string",
  453. "sanitize": true,
  454. "maxLength": 256
  455. },
  456. "data_type": {
  457. "type": "string",
  458. "sanitize": true,
  459. "maxLength": 128
  460. },
  461. "reason": {
  462. "type": "string",
  463. "sanitize": true,
  464. "maxLength": 256
  465. }
  466. }
  467. },
  468. "missing_tool": {
  469. "defaultMax": 20,
  470. "fields": {
  471. "alternatives": {
  472. "type": "string",
  473. "sanitize": true,
  474. "maxLength": 512
  475. },
  476. "reason": {
  477. "required": true,
  478. "type": "string",
  479. "sanitize": true,
  480. "maxLength": 256
  481. },
  482. "tool": {
  483. "type": "string",
  484. "sanitize": true,
  485. "maxLength": 128
  486. }
  487. }
  488. },
  489. "noop": {
  490. "defaultMax": 1,
  491. "fields": {
  492. "message": {
  493. "required": true,
  494. "type": "string",
  495. "sanitize": true,
  496. "maxLength": 65000
  497. }
  498. }
  499. },
  500. "report_incomplete": {
  501. "defaultMax": 5,
  502. "fields": {
  503. "details": {
  504. "type": "string",
  505. "sanitize": true,
  506. "maxLength": 65000
  507. },
  508. "reason": {
  509. "required": true,
  510. "type": "string",
  511. "sanitize": true,
  512. "maxLength": 1024
  513. }
  514. }
  515. }
  516. }
  517. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  518. with:
  519. script: |
  520. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  521. setupGlobals(core, github, context, exec, io, getOctokit);
  522. const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_safe_outputs_tools.cjs');
  523. await main();
  524. - name: Generate Safe Outputs MCP Server Config
  525. id: safe-outputs-config
  526. run: |
  527. # Generate a secure random API key (360 bits of entropy, 40+ chars)
  528. # Mask immediately to prevent timing vulnerabilities
  529. API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
  530. echo "::add-mask::${API_KEY}"
  531. PORT=3001
  532. # Set outputs for next steps
  533. {
  534. echo "safe_outputs_api_key=${API_KEY}"
  535. echo "safe_outputs_port=${PORT}"
  536. } >> "$GITHUB_OUTPUT"
  537. echo "Safe Outputs MCP server will run on port ${PORT}"
  538. - name: Start Safe Outputs MCP HTTP Server
  539. id: safe-outputs-start
  540. env:
  541. DEBUG: '*'
  542. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  543. GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-config.outputs.safe_outputs_port }}
  544. GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-config.outputs.safe_outputs_api_key }}
  545. GH_AW_SAFE_OUTPUTS_TOOLS_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/tools.json
  546. GH_AW_SAFE_OUTPUTS_CONFIG_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/config.json
  547. GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs
  548. run: |
  549. # Environment variables are set above to prevent template injection
  550. export DEBUG
  551. export GH_AW_SAFE_OUTPUTS
  552. export GH_AW_SAFE_OUTPUTS_PORT
  553. export GH_AW_SAFE_OUTPUTS_API_KEY
  554. export GH_AW_SAFE_OUTPUTS_TOOLS_PATH
  555. export GH_AW_SAFE_OUTPUTS_CONFIG_PATH
  556. export GH_AW_MCP_LOG_DIR
  557. bash "${RUNNER_TEMP}/gh-aw/actions/start_safe_outputs_server.sh"
  558. - name: Start MCP Gateway
  559. id: start-mcp-gateway
  560. env:
  561. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  562. GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-start.outputs.api_key }}
  563. GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-start.outputs.port }}
  564. GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  565. run: |
  566. set -eo pipefail
  567. mkdir -p /tmp/gh-aw/mcp-config
  568. # Export gateway environment variables for MCP config and gateway script
  569. export MCP_GATEWAY_PORT="80"
  570. export MCP_GATEWAY_DOMAIN="host.docker.internal"
  571. MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
  572. echo "::add-mask::${MCP_GATEWAY_API_KEY}"
  573. export MCP_GATEWAY_API_KEY
  574. export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads"
  575. mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}"
  576. export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288"
  577. export DEBUG="*"
  578. export GH_AW_ENGINE="claude"
  579. export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.19'
  580. cat << GH_AW_MCP_CONFIG_f2bb9d437316fc33_EOF | bash "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh"
  581. {
  582. "mcpServers": {
  583. "github": {
  584. "container": "ghcr.io/github/github-mcp-server:v0.32.0",
  585. "env": {
  586. "GITHUB_HOST": "$GITHUB_SERVER_URL",
  587. "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_MCP_SERVER_TOKEN",
  588. "GITHUB_READ_ONLY": "1",
  589. "GITHUB_TOOLSETS": "context,repos,issues,pull_requests"
  590. },
  591. "guard-policies": {
  592. "allow-only": {
  593. "approval-labels": ${{ steps.parse-guard-vars.outputs.approval_labels }},
  594. "blocked-users": ${{ steps.parse-guard-vars.outputs.blocked_users }},
  595. "min-integrity": "none",
  596. "repos": "all",
  597. "trusted-users": ${{ steps.parse-guard-vars.outputs.trusted_users }}
  598. }
  599. }
  600. },
  601. "safeoutputs": {
  602. "type": "http",
  603. "url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT",
  604. "headers": {
  605. "Authorization": "$GH_AW_SAFE_OUTPUTS_API_KEY"
  606. },
  607. "guard-policies": {
  608. "write-sink": {
  609. "accept": [
  610. "*"
  611. ]
  612. }
  613. }
  614. }
  615. },
  616. "gateway": {
  617. "port": $MCP_GATEWAY_PORT,
  618. "domain": "${MCP_GATEWAY_DOMAIN}",
  619. "apiKey": "${MCP_GATEWAY_API_KEY}",
  620. "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}"
  621. }
  622. }
  623. GH_AW_MCP_CONFIG_f2bb9d437316fc33_EOF
  624. - name: Download activation artifact
  625. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  626. with:
  627. name: activation
  628. path: /tmp/gh-aw
  629. - name: Clean git credentials
  630. continue-on-error: true
  631. run: bash "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh"
  632. - name: Execute Claude Code CLI
  633. id: agentic_execution
  634. # Allowed tools (sorted):
  635. # - Bash
  636. # - BashOutput
  637. # - Edit
  638. # - ExitPlanMode
  639. # - Glob
  640. # - Grep
  641. # - KillBash
  642. # - LS
  643. # - MultiEdit
  644. # - NotebookEdit
  645. # - NotebookRead
  646. # - Read
  647. # - Task
  648. # - TodoWrite
  649. # - Write
  650. # - mcp__github__download_workflow_run_artifact
  651. # - mcp__github__get_code_scanning_alert
  652. # - mcp__github__get_commit
  653. # - mcp__github__get_dependabot_alert
  654. # - mcp__github__get_discussion
  655. # - mcp__github__get_discussion_comments
  656. # - mcp__github__get_file_contents
  657. # - mcp__github__get_job_logs
  658. # - mcp__github__get_label
  659. # - mcp__github__get_latest_release
  660. # - mcp__github__get_me
  661. # - mcp__github__get_notification_details
  662. # - mcp__github__get_pull_request
  663. # - mcp__github__get_pull_request_comments
  664. # - mcp__github__get_pull_request_diff
  665. # - mcp__github__get_pull_request_files
  666. # - mcp__github__get_pull_request_review_comments
  667. # - mcp__github__get_pull_request_reviews
  668. # - mcp__github__get_pull_request_status
  669. # - mcp__github__get_release_by_tag
  670. # - mcp__github__get_secret_scanning_alert
  671. # - mcp__github__get_tag
  672. # - mcp__github__get_workflow_run
  673. # - mcp__github__get_workflow_run_logs
  674. # - mcp__github__get_workflow_run_usage
  675. # - mcp__github__issue_read
  676. # - mcp__github__list_branches
  677. # - mcp__github__list_code_scanning_alerts
  678. # - mcp__github__list_commits
  679. # - mcp__github__list_dependabot_alerts
  680. # - mcp__github__list_discussion_categories
  681. # - mcp__github__list_discussions
  682. # - mcp__github__list_issue_types
  683. # - mcp__github__list_issues
  684. # - mcp__github__list_label
  685. # - mcp__github__list_notifications
  686. # - mcp__github__list_pull_requests
  687. # - mcp__github__list_releases
  688. # - mcp__github__list_secret_scanning_alerts
  689. # - mcp__github__list_starred_repositories
  690. # - mcp__github__list_tags
  691. # - mcp__github__list_workflow_jobs
  692. # - mcp__github__list_workflow_run_artifacts
  693. # - mcp__github__list_workflow_runs
  694. # - mcp__github__list_workflows
  695. # - mcp__github__pull_request_read
  696. # - mcp__github__search_code
  697. # - mcp__github__search_issues
  698. # - mcp__github__search_orgs
  699. # - mcp__github__search_pull_requests
  700. # - mcp__github__search_repositories
  701. # - mcp__github__search_users
  702. timeout-minutes: 10
  703. run: |
  704. set -o pipefail
  705. touch /tmp/gh-aw/agent-step-summary.md
  706. (umask 177 && touch /tmp/gh-aw/agent-stdio.log)
  707. # shellcheck disable=SC1003
  708. sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --tty --env-all --exclude-env ANTHROPIC_API_KEY --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --allow-domains '*.githubusercontent.com,anthropic.com,api-inference.modelscope.cn,api.anthropic.com,api.github.com,api.minimaxi.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,cdn.playwright.dev,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,files.pythonhosted.org,ghcr.io,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,open.bigmodel.cn,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,playwright.download.prss.microsoft.com,ppa.launchpad.net,pypi.org,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,sentry.io,statsig.anthropic.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com' --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.20 --skip-pull --enable-api-proxy --anthropic-api-target api.minimaxi.com --anthropic-api-base-path /anthropic \
  709. -- /bin/bash -c 'export PATH="$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && claude --print --no-chrome --mcp-config /tmp/gh-aw/mcp-config/mcp-servers.json --allowed-tools Bash,BashOutput,Edit,ExitPlanMode,Glob,Grep,KillBash,LS,MultiEdit,NotebookEdit,NotebookRead,Read,Task,TodoWrite,Write,mcp__github__download_workflow_run_artifact,mcp__github__get_code_scanning_alert,mcp__github__get_commit,mcp__github__get_dependabot_alert,mcp__github__get_discussion,mcp__github__get_discussion_comments,mcp__github__get_file_contents,mcp__github__get_job_logs,mcp__github__get_label,mcp__github__get_latest_release,mcp__github__get_me,mcp__github__get_notification_details,mcp__github__get_pull_request,mcp__github__get_pull_request_comments,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_files,mcp__github__get_pull_request_review_comments,mcp__github__get_pull_request_reviews,mcp__github__get_pull_request_status,mcp__github__get_release_by_tag,mcp__github__get_secret_scanning_alert,mcp__github__get_tag,mcp__github__get_workflow_run,mcp__github__get_workflow_run_logs,mcp__github__get_workflow_run_usage,mcp__github__issue_read,mcp__github__list_branches,mcp__github__list_code_scanning_alerts,mcp__github__list_commits,mcp__github__list_dependabot_alerts,mcp__github__list_discussion_categories,mcp__github__list_discussions,mcp__github__list_issue_types,mcp__github__list_issues,mcp__github__list_label,mcp__github__list_notifications,mcp__github__list_pull_requests,mcp__github__list_releases,mcp__github__list_secret_scanning_alerts,mcp__github__list_starred_repositories,mcp__github__list_tags,mcp__github__list_workflow_jobs,mcp__github__list_workflow_run_artifacts,mcp__github__list_workflow_runs,mcp__github__list_workflows,mcp__github__pull_request_read,mcp__github__search_code,mcp__github__search_issues,mcp__github__search_orgs,mcp__github__search_pull_requests,mcp__github__search_repositories,mcp__github__search_users --debug-file /tmp/gh-aw/agent-stdio.log --verbose --permission-mode bypassPermissions --output-format stream-json "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log
  710. env:
  711. ANTHROPIC_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
  712. ANTHROPIC_BASE_URL: https://api.minimaxi.com/anthropic
  713. ANTHROPIC_MODEL: MiniMax-M2.7
  714. BASH_DEFAULT_TIMEOUT_MS: 60000
  715. BASH_MAX_TIMEOUT_MS: 60000
  716. DISABLE_BUG_COMMAND: 1
  717. DISABLE_ERROR_REPORTING: 1
  718. DISABLE_TELEMETRY: 1
  719. GH_AW_MCP_CONFIG: /tmp/gh-aw/mcp-config/mcp-servers.json
  720. GH_AW_PHASE: agent
  721. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  722. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  723. GH_AW_VERSION: v0.68.3
  724. GITHUB_AW: true
  725. GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md
  726. GITHUB_WORKSPACE: ${{ github.workspace }}
  727. GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
  728. GIT_AUTHOR_NAME: github-actions[bot]
  729. GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
  730. GIT_COMMITTER_NAME: github-actions[bot]
  731. MCP_TIMEOUT: 120000
  732. MCP_TOOL_TIMEOUT: 60000
  733. - name: Configure Git credentials
  734. env:
  735. REPO_NAME: ${{ github.repository }}
  736. SERVER_URL: ${{ github.server_url }}
  737. GITHUB_TOKEN: ${{ github.token }}
  738. run: |
  739. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  740. git config --global user.name "github-actions[bot]"
  741. git config --global am.keepcr true
  742. # Re-authenticate git with GitHub token
  743. SERVER_URL_STRIPPED="${SERVER_URL#https://}"
  744. git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
  745. echo "Git configured with standard GitHub Actions identity"
  746. - name: Stop MCP Gateway
  747. if: always()
  748. continue-on-error: true
  749. env:
  750. MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }}
  751. MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }}
  752. GATEWAY_PID: ${{ steps.start-mcp-gateway.outputs.gateway-pid }}
  753. run: |
  754. bash "${RUNNER_TEMP}/gh-aw/actions/stop_mcp_gateway.sh" "$GATEWAY_PID"
  755. - name: Redact secrets in logs
  756. if: always()
  757. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  758. with:
  759. script: |
  760. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  761. setupGlobals(core, github, context, exec, io, getOctokit);
  762. const { main } = require('${{ runner.temp }}/gh-aw/actions/redact_secrets.cjs');
  763. await main();
  764. env:
  765. GH_AW_SECRET_NAMES: 'GH_AW_GITHUB_MCP_SERVER_TOKEN,GH_AW_GITHUB_TOKEN,GITHUB_TOKEN,MINIMAX_API_KEY'
  766. SECRET_GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }}
  767. SECRET_GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }}
  768. SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  769. SECRET_MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
  770. - name: Append agent step summary
  771. if: always()
  772. run: bash "${RUNNER_TEMP}/gh-aw/actions/append_agent_step_summary.sh"
  773. - name: Copy Safe Outputs
  774. if: always()
  775. env:
  776. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  777. run: |
  778. mkdir -p /tmp/gh-aw
  779. cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true
  780. - name: Ingest agent output
  781. id: collect_output
  782. if: always()
  783. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  784. env:
  785. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  786. GH_AW_ALLOWED_DOMAINS: "*.githubusercontent.com,anthropic.com,api-inference.modelscope.cn,api.anthropic.com,api.github.com,api.minimaxi.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,cdn.playwright.dev,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,files.pythonhosted.org,ghcr.io,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,open.bigmodel.cn,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,playwright.download.prss.microsoft.com,ppa.launchpad.net,pypi.org,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,sentry.io,statsig.anthropic.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com"
  787. GITHUB_SERVER_URL: ${{ github.server_url }}
  788. GITHUB_API_URL: ${{ github.api_url }}
  789. with:
  790. script: |
  791. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  792. setupGlobals(core, github, context, exec, io, getOctokit);
  793. const { main } = require('${{ runner.temp }}/gh-aw/actions/collect_ndjson_output.cjs');
  794. await main();
  795. - name: Parse agent logs for step summary
  796. if: always()
  797. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  798. env:
  799. GH_AW_AGENT_OUTPUT: /tmp/gh-aw/agent-stdio.log
  800. with:
  801. script: |
  802. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  803. setupGlobals(core, github, context, exec, io, getOctokit);
  804. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_claude_log.cjs');
  805. await main();
  806. - name: Parse MCP Gateway logs for step summary
  807. if: always()
  808. id: parse-mcp-gateway
  809. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  810. with:
  811. script: |
  812. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  813. setupGlobals(core, github, context, exec, io, getOctokit);
  814. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_mcp_gateway_log.cjs');
  815. await main();
  816. - name: Print firewall logs
  817. if: always()
  818. continue-on-error: true
  819. env:
  820. AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
  821. run: |
  822. # Fix permissions on firewall logs so they can be uploaded as artifacts
  823. # AWF runs with sudo, creating files owned by root
  824. sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
  825. # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step)
  826. if command -v awf &> /dev/null; then
  827. awf logs summary | tee -a "$GITHUB_STEP_SUMMARY"
  828. else
  829. echo 'AWF binary not installed, skipping firewall log summary'
  830. fi
  831. - name: Parse token usage for step summary
  832. if: always()
  833. continue-on-error: true
  834. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  835. with:
  836. script: |
  837. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  838. setupGlobals(core, github, context, exec, io, getOctokit);
  839. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_token_usage.cjs');
  840. await main();
  841. - name: Write agent output placeholder if missing
  842. if: always()
  843. run: |
  844. if [ ! -f /tmp/gh-aw/agent_output.json ]; then
  845. echo '{"items":[]}' > /tmp/gh-aw/agent_output.json
  846. fi
  847. - name: Upload agent artifacts
  848. if: always()
  849. continue-on-error: true
  850. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  851. with:
  852. name: agent
  853. path: |
  854. /tmp/gh-aw/aw-prompts/prompt.txt
  855. /tmp/gh-aw/mcp-logs/
  856. /tmp/gh-aw/proxy-logs/
  857. !/tmp/gh-aw/proxy-logs/proxy-tls/
  858. /tmp/gh-aw/agent_usage.json
  859. /tmp/gh-aw/agent-stdio.log
  860. /tmp/gh-aw/agent/
  861. /tmp/gh-aw/github_rate_limits.jsonl
  862. /tmp/gh-aw/safeoutputs.jsonl
  863. /tmp/gh-aw/agent_output.json
  864. /tmp/gh-aw/aw-*.patch
  865. /tmp/gh-aw/aw-*.bundle
  866. /tmp/gh-aw/sandbox/firewall/logs/
  867. /tmp/gh-aw/sandbox/firewall/audit/
  868. if-no-files-found: ignore
  869. conclusion:
  870. needs:
  871. - activation
  872. - agent
  873. - detection
  874. - safe_outputs
  875. if: >
  876. always() && (needs.agent.result != 'skipped' || needs.activation.outputs.lockdown_check_failed == 'true' ||
  877. needs.activation.outputs.stale_lock_file_failed == 'true')
  878. runs-on: ubuntu-slim
  879. permissions:
  880. contents: read
  881. discussions: write
  882. issues: write
  883. pull-requests: write
  884. concurrency:
  885. group: "gh-aw-conclusion-pr-review-intent"
  886. cancel-in-progress: false
  887. outputs:
  888. incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }}
  889. noop_message: ${{ steps.noop.outputs.noop_message }}
  890. tools_reported: ${{ steps.missing_tool.outputs.tools_reported }}
  891. total_count: ${{ steps.missing_tool.outputs.total_count }}
  892. steps:
  893. - name: Setup Scripts
  894. id: setup
  895. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  896. with:
  897. destination: ${{ runner.temp }}/gh-aw/actions
  898. job-name: ${{ github.job }}
  899. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  900. - name: Download agent output artifact
  901. id: download-agent-output
  902. continue-on-error: true
  903. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  904. with:
  905. name: agent
  906. path: /tmp/gh-aw/
  907. - name: Setup agent output environment variable
  908. id: setup-agent-output-env
  909. if: steps.download-agent-output.outcome == 'success'
  910. run: |
  911. mkdir -p /tmp/gh-aw/
  912. find "/tmp/gh-aw/" -type f -print
  913. echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT"
  914. - name: Process no-op messages
  915. id: noop
  916. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  917. env:
  918. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  919. GH_AW_NOOP_MAX: "1"
  920. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  921. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  922. GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }}
  923. GH_AW_NOOP_REPORT_AS_ISSUE: "true"
  924. with:
  925. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  926. script: |
  927. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  928. setupGlobals(core, github, context, exec, io, getOctokit);
  929. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_noop_message.cjs');
  930. await main();
  931. - name: Log detection run
  932. id: detection_runs
  933. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  934. env:
  935. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  936. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  937. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  938. GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }}
  939. GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }}
  940. with:
  941. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  942. script: |
  943. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  944. setupGlobals(core, github, context, exec, io, getOctokit);
  945. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_detection_runs.cjs');
  946. await main();
  947. - name: Record missing tool
  948. id: missing_tool
  949. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  950. env:
  951. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  952. GH_AW_MISSING_TOOL_CREATE_ISSUE: "true"
  953. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  954. with:
  955. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  956. script: |
  957. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  958. setupGlobals(core, github, context, exec, io, getOctokit);
  959. const { main } = require('${{ runner.temp }}/gh-aw/actions/missing_tool.cjs');
  960. await main();
  961. - name: Record incomplete
  962. id: report_incomplete
  963. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  964. env:
  965. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  966. GH_AW_REPORT_INCOMPLETE_CREATE_ISSUE: "true"
  967. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  968. with:
  969. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  970. script: |
  971. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  972. setupGlobals(core, github, context, exec, io, getOctokit);
  973. const { main } = require('${{ runner.temp }}/gh-aw/actions/report_incomplete_handler.cjs');
  974. await main();
  975. - name: Handle agent failure
  976. id: handle_agent_failure
  977. if: always()
  978. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  979. env:
  980. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  981. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  982. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  983. GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }}
  984. GH_AW_WORKFLOW_ID: "pr-review-intent"
  985. GH_AW_ENGINE_ID: "claude"
  986. GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }}
  987. GH_AW_CHECKOUT_PR_SUCCESS: ${{ needs.agent.outputs.checkout_pr_success }}
  988. GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }}
  989. GH_AW_STALE_LOCK_FILE_FAILED: ${{ needs.activation.outputs.stale_lock_file_failed }}
  990. GH_AW_GROUP_REPORTS: "false"
  991. GH_AW_FAILURE_REPORT_AS_ISSUE: "true"
  992. GH_AW_TIMEOUT_MINUTES: "10"
  993. with:
  994. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  995. script: |
  996. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  997. setupGlobals(core, github, context, exec, io, getOctokit);
  998. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_agent_failure.cjs');
  999. await main();
  1000. detection:
  1001. needs:
  1002. - activation
  1003. - agent
  1004. if: >
  1005. always() && needs.agent.result != 'skipped' && (needs.agent.outputs.output_types != '' || needs.agent.outputs.has_patch == 'true')
  1006. runs-on: ubuntu-latest
  1007. permissions:
  1008. contents: read
  1009. outputs:
  1010. detection_conclusion: ${{ steps.detection_conclusion.outputs.conclusion }}
  1011. detection_reason: ${{ steps.detection_conclusion.outputs.reason }}
  1012. detection_success: ${{ steps.detection_conclusion.outputs.success }}
  1013. steps:
  1014. - name: Setup Scripts
  1015. id: setup
  1016. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  1017. with:
  1018. destination: ${{ runner.temp }}/gh-aw/actions
  1019. job-name: ${{ github.job }}
  1020. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  1021. - name: Download agent output artifact
  1022. id: download-agent-output
  1023. continue-on-error: true
  1024. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  1025. with:
  1026. name: agent
  1027. path: /tmp/gh-aw/
  1028. - name: Setup agent output environment variable
  1029. id: setup-agent-output-env
  1030. if: steps.download-agent-output.outcome == 'success'
  1031. run: |
  1032. mkdir -p /tmp/gh-aw/
  1033. find "/tmp/gh-aw/" -type f -print
  1034. echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT"
  1035. - name: Checkout repository for patch context
  1036. if: needs.agent.outputs.has_patch == 'true'
  1037. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  1038. with:
  1039. persist-credentials: false
  1040. # --- Threat Detection ---
  1041. - name: Clean stale firewall files from agent artifact
  1042. run: |
  1043. rm -rf /tmp/gh-aw/sandbox/firewall/logs
  1044. rm -rf /tmp/gh-aw/sandbox/firewall/audit
  1045. - name: Download container images
  1046. run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.25.20 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20 ghcr.io/github/gh-aw-firewall/squid:0.25.20
  1047. - name: Check if detection needed
  1048. id: detection_guard
  1049. if: always()
  1050. env:
  1051. OUTPUT_TYPES: ${{ needs.agent.outputs.output_types }}
  1052. HAS_PATCH: ${{ needs.agent.outputs.has_patch }}
  1053. run: |
  1054. if [[ -n "$OUTPUT_TYPES" || "$HAS_PATCH" == "true" ]]; then
  1055. echo "run_detection=true" >> "$GITHUB_OUTPUT"
  1056. echo "Detection will run: output_types=$OUTPUT_TYPES, has_patch=$HAS_PATCH"
  1057. else
  1058. echo "run_detection=false" >> "$GITHUB_OUTPUT"
  1059. echo "Detection skipped: no agent outputs or patches to analyze"
  1060. fi
  1061. - name: Clear MCP configuration for detection
  1062. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1063. run: |
  1064. rm -f /tmp/gh-aw/mcp-config/mcp-servers.json
  1065. rm -f /home/runner/.copilot/mcp-config.json
  1066. rm -f "$GITHUB_WORKSPACE/.gemini/settings.json"
  1067. - name: Prepare threat detection files
  1068. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1069. run: |
  1070. mkdir -p /tmp/gh-aw/threat-detection/aw-prompts
  1071. cp /tmp/gh-aw/aw-prompts/prompt.txt /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt 2>/dev/null || true
  1072. cp /tmp/gh-aw/agent_output.json /tmp/gh-aw/threat-detection/agent_output.json 2>/dev/null || true
  1073. for f in /tmp/gh-aw/aw-*.patch; do
  1074. [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1075. done
  1076. for f in /tmp/gh-aw/aw-*.bundle; do
  1077. [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1078. done
  1079. echo "Prepared threat detection files:"
  1080. ls -la /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1081. - name: Setup threat detection
  1082. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1083. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  1084. env:
  1085. WORKFLOW_NAME: "PR Review Intent"
  1086. WORKFLOW_DESCRIPTION: "自动审计 Pull Request 的代码意图、隐含约束、实现对齐情况与发布风险"
  1087. HAS_PATCH: ${{ needs.agent.outputs.has_patch }}
  1088. with:
  1089. script: |
  1090. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1091. setupGlobals(core, github, context, exec, io, getOctokit);
  1092. const { main } = require('${{ runner.temp }}/gh-aw/actions/setup_threat_detection.cjs');
  1093. await main();
  1094. - name: Ensure threat-detection directory and log
  1095. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1096. run: |
  1097. mkdir -p /tmp/gh-aw/threat-detection
  1098. touch /tmp/gh-aw/threat-detection/detection.log
  1099. - name: Setup Node.js
  1100. uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
  1101. with:
  1102. node-version: '24'
  1103. package-manager-cache: false
  1104. - name: Install AWF binary
  1105. run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.25.20
  1106. - name: Install Claude Code CLI
  1107. run: npm install --ignore-scripts -g @anthropic-ai/claude-code@2.1.98
  1108. - name: Execute Claude Code CLI
  1109. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1110. id: detection_agentic_execution
  1111. # Allowed tools (sorted):
  1112. # - Bash
  1113. # - BashOutput
  1114. # - ExitPlanMode
  1115. # - Glob
  1116. # - Grep
  1117. # - KillBash
  1118. # - LS
  1119. # - NotebookRead
  1120. # - Read
  1121. # - Task
  1122. # - TodoWrite
  1123. timeout-minutes: 20
  1124. run: |
  1125. set -o pipefail
  1126. touch /tmp/gh-aw/agent-step-summary.md
  1127. (umask 177 && touch /tmp/gh-aw/threat-detection/detection.log)
  1128. # shellcheck disable=SC1003
  1129. sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --tty --env-all --exclude-env ANTHROPIC_API_KEY --allow-domains '*.githubusercontent.com,anthropic.com,api.anthropic.com,api.github.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,cdn.playwright.dev,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,files.pythonhosted.org,ghcr.io,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,playwright.download.prss.microsoft.com,ppa.launchpad.net,pypi.org,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,sentry.io,statsig.anthropic.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com' --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.20 --skip-pull --enable-api-proxy --anthropic-api-target api.minimaxi.com --anthropic-api-base-path /anthropic \
  1130. -- /bin/bash -c 'export PATH="$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && claude --print --no-chrome --allowed-tools Bash,BashOutput,ExitPlanMode,Glob,Grep,KillBash,LS,NotebookRead,Read,Task,TodoWrite --debug-file /tmp/gh-aw/threat-detection/detection.log --verbose --permission-mode bypassPermissions --output-format stream-json "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/threat-detection/detection.log
  1131. env:
  1132. ANTHROPIC_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
  1133. ANTHROPIC_BASE_URL: https://api.minimaxi.com/anthropic
  1134. ANTHROPIC_MODEL: MiniMax-M2.7
  1135. BASH_DEFAULT_TIMEOUT_MS: 60000
  1136. BASH_MAX_TIMEOUT_MS: 60000
  1137. DISABLE_BUG_COMMAND: 1
  1138. DISABLE_ERROR_REPORTING: 1
  1139. DISABLE_TELEMETRY: 1
  1140. GH_AW_PHASE: detection
  1141. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  1142. GH_AW_VERSION: v0.68.3
  1143. GITHUB_AW: true
  1144. GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md
  1145. GITHUB_WORKSPACE: ${{ github.workspace }}
  1146. GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
  1147. GIT_AUTHOR_NAME: github-actions[bot]
  1148. GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
  1149. GIT_COMMITTER_NAME: github-actions[bot]
  1150. MCP_TIMEOUT: 120000
  1151. MCP_TOOL_TIMEOUT: 60000
  1152. - name: Upload threat detection log
  1153. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1154. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  1155. with:
  1156. name: detection
  1157. path: /tmp/gh-aw/threat-detection/detection.log
  1158. if-no-files-found: ignore
  1159. - name: Parse and conclude threat detection
  1160. id: detection_conclusion
  1161. if: always()
  1162. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  1163. env:
  1164. RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
  1165. GH_AW_DETECTION_CONTINUE_ON_ERROR: "true"
  1166. with:
  1167. script: |
  1168. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1169. setupGlobals(core, github, context, exec, io, getOctokit);
  1170. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_threat_detection_results.cjs');
  1171. await main();
  1172. pre_activation:
  1173. runs-on: ubuntu-slim
  1174. outputs:
  1175. activated: ${{ steps.check_membership.outputs.is_team_member == 'true' }}
  1176. matched_command: ''
  1177. setup-trace-id: ${{ steps.setup.outputs.trace-id }}
  1178. steps:
  1179. - name: Setup Scripts
  1180. id: setup
  1181. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  1182. with:
  1183. destination: ${{ runner.temp }}/gh-aw/actions
  1184. job-name: ${{ github.job }}
  1185. - name: Check team membership for workflow
  1186. id: check_membership
  1187. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  1188. env:
  1189. GH_AW_REQUIRED_ROLES: "admin,maintainer,write"
  1190. with:
  1191. github-token: ${{ secrets.GITHUB_TOKEN }}
  1192. script: |
  1193. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1194. setupGlobals(core, github, context, exec, io, getOctokit);
  1195. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_membership.cjs');
  1196. await main();
  1197. safe_outputs:
  1198. needs:
  1199. - activation
  1200. - agent
  1201. - detection
  1202. if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success'
  1203. runs-on: ubuntu-slim
  1204. permissions:
  1205. contents: read
  1206. discussions: write
  1207. issues: write
  1208. pull-requests: write
  1209. timeout-minutes: 15
  1210. env:
  1211. GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/pr-review-intent"
  1212. GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }}
  1213. GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }}
  1214. GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }}
  1215. GH_AW_ENGINE_ID: "claude"
  1216. GH_AW_ENGINE_MODEL: "MiniMax-M2.7"
  1217. GH_AW_WORKFLOW_ID: "pr-review-intent"
  1218. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1219. outputs:
  1220. code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }}
  1221. code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }}
  1222. comment_id: ${{ steps.process_safe_outputs.outputs.comment_id }}
  1223. comment_url: ${{ steps.process_safe_outputs.outputs.comment_url }}
  1224. create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }}
  1225. create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }}
  1226. process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }}
  1227. process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }}
  1228. steps:
  1229. - name: Setup Scripts
  1230. id: setup
  1231. uses: github/gh-aw-actions/setup@ba90f2186d7ad780ec640f364005fa24e797b360 # v0.68.3
  1232. with:
  1233. destination: ${{ runner.temp }}/gh-aw/actions
  1234. job-name: ${{ github.job }}
  1235. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  1236. - name: Download agent output artifact
  1237. id: download-agent-output
  1238. continue-on-error: true
  1239. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  1240. with:
  1241. name: agent
  1242. path: /tmp/gh-aw/
  1243. - name: Setup agent output environment variable
  1244. id: setup-agent-output-env
  1245. if: steps.download-agent-output.outcome == 'success'
  1246. run: |
  1247. mkdir -p /tmp/gh-aw/
  1248. find "/tmp/gh-aw/" -type f -print
  1249. echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT"
  1250. - name: Configure GH_HOST for enterprise compatibility
  1251. id: ghes-host-config
  1252. shell: bash
  1253. run: |
  1254. # Derive GH_HOST from GITHUB_SERVER_URL so the gh CLI targets the correct
  1255. # GitHub instance (GHES/GHEC). On github.com this is a harmless no-op.
  1256. GH_HOST="${GITHUB_SERVER_URL#https://}"
  1257. GH_HOST="${GH_HOST#http://}"
  1258. echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV"
  1259. - name: Process Safe Outputs
  1260. id: process_safe_outputs
  1261. uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9
  1262. env:
  1263. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1264. GH_AW_ALLOWED_DOMAINS: "*.githubusercontent.com,anthropic.com,api-inference.modelscope.cn,api.anthropic.com,api.github.com,api.minimaxi.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,cdn.playwright.dev,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,files.pythonhosted.org,ghcr.io,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,open.bigmodel.cn,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,playwright.download.prss.microsoft.com,ppa.launchpad.net,pypi.org,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,sentry.io,statsig.anthropic.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com"
  1265. GITHUB_SERVER_URL: ${{ github.server_url }}
  1266. GITHUB_API_URL: ${{ github.api_url }}
  1267. GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"add_comment\":{\"max\":1,\"target\":\"triggering\"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{}}"
  1268. with:
  1269. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1270. script: |
  1271. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1272. setupGlobals(core, github, context, exec, io, getOctokit);
  1273. const { main } = require('${{ runner.temp }}/gh-aw/actions/safe_output_handler_manager.cjs');
  1274. await main();
  1275. - name: Upload Safe Outputs Items
  1276. if: always()
  1277. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  1278. with:
  1279. name: safe-outputs-items
  1280. path: |
  1281. /tmp/gh-aw/safe-output-items.jsonl
  1282. /tmp/gh-aw/temporary-id-map.json
  1283. if-no-files-found: ignore