pr-review-intent.lock.yml 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. # gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"4f9b09824c761259df93e85198cddc36d679de09d9367d090d1f80b30ad39ae7","body_hash":"fc2de9c53c0ecaa9cc183dbac863c4f2e44d941a8fd523c78c985ce9d724a1fc","compiler_version":"v0.79.4","strict":true,"agent_id":"codex","agent_model":"gpt-5.4","engine_versions":{"codex":"0.137.0"}}
  2. # gh-aw-manifest: {"version":1,"secrets":["CODEX_API_KEY","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN","OPENAI_API_KEY","PIXEL_API_KEY"],"actions":[{"repo":"actions/checkout","sha":"df4cb1c069e1874edd31b4311f1884172cec0e10","version":"v6.0.3"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"7cfd95b59ca996b7e2bebd6222e21ddd187a4e91","version":"v0.79.4"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.0"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.0"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.0"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.25","digest":"sha256:c10331ad17668ef89f38f5e356678788a40b0cd5fef96e8f92e1d9c1de47cbaa","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.25@sha256:c10331ad17668ef89f38f5e356678788a40b0cd5fef96e8f92e1d9c1de47cbaa"},{"image":"ghcr.io/github/github-mcp-server:v1.1.2","digest":"sha256:30197479d8036c7811892bc07e06f9a05c9ef3cdd79bc59f256d50647f95788c","pinned_image":"ghcr.io/github/github-mcp-server:v1.1.2@sha256:30197479d8036c7811892bc07e06f9a05c9ef3cdd79bc59f256d50647f95788c"},{"image":"node:lts-alpine","digest":"sha256:2bdb65ed1dab192432bc31c95f94155ca5ad7fc1392fb7eb7526ab682fa5bf14","pinned_image":"node:lts-alpine@sha256:2bdb65ed1dab192432bc31c95f94155ca5ad7fc1392fb7eb7526ab682fa5bf14"}]}
  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.79.4). 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. # - CODEX_API_KEY
  34. # - GH_AW_GITHUB_MCP_SERVER_TOKEN
  35. # - GH_AW_GITHUB_TOKEN
  36. # - GITHUB_TOKEN
  37. # - OPENAI_API_KEY
  38. # - PIXEL_API_KEY
  39. #
  40. # Custom actions used:
  41. # - actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
  42. # - actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  43. # - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  44. # - actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
  45. # - actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  46. # - github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  47. #
  48. # Container images used:
  49. # - ghcr.io/github/gh-aw-firewall/agent:0.27.0
  50. # - ghcr.io/github/gh-aw-firewall/api-proxy:0.27.0
  51. # - ghcr.io/github/gh-aw-firewall/squid:0.27.0
  52. # - ghcr.io/github/gh-aw-mcpg:v0.3.25@sha256:c10331ad17668ef89f38f5e356678788a40b0cd5fef96e8f92e1d9c1de47cbaa
  53. # - ghcr.io/github/github-mcp-server:v1.1.2@sha256:30197479d8036c7811892bc07e06f9a05c9ef3cdd79bc59f256d50647f95788c
  54. # - node:lts-alpine@sha256:2bdb65ed1dab192432bc31c95f94155ca5ad7fc1392fb7eb7526ab682fa5bf14
  55. name: "PR Review Intent"
  56. on:
  57. pull_request_target:
  58. branches:
  59. - dev
  60. types:
  61. - opened
  62. - reopened
  63. # roles: all # Roles processed as role check in pre-activation job
  64. permissions: {}
  65. concurrency:
  66. group: "gh-aw-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}"
  67. cancel-in-progress: true
  68. run-name: "PR Review Intent"
  69. jobs:
  70. activation:
  71. runs-on: ubuntu-slim
  72. permissions:
  73. actions: read
  74. contents: read
  75. env:
  76. GH_AW_MAX_DAILY_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }}
  77. outputs:
  78. body: ${{ steps.sanitized.outputs.body }}
  79. comment_id: ""
  80. comment_repo: ""
  81. daily_effective_workflow_exceeded: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_effective_workflow_exceeded == 'true' }}
  82. daily_effective_workflow_threshold: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_effective_workflow_threshold || '' }}
  83. daily_effective_workflow_total_effective_tokens: ${{ steps.daily-effective-workflow-guardrail.outputs.daily_effective_workflow_total_effective_tokens || '' }}
  84. engine_id: ${{ steps.generate_aw_info.outputs.engine_id }}
  85. lockdown_check_failed: ${{ steps.generate_aw_info.outputs.lockdown_check_failed == 'true' }}
  86. model: ${{ steps.generate_aw_info.outputs.model }}
  87. secret_verification_result: ${{ steps.validate-secret.outputs.verification_result }}
  88. setup-parent-span-id: ${{ steps.setup.outputs.parent-span-id || steps.setup.outputs.span-id }}
  89. setup-span-id: ${{ steps.setup.outputs.span-id }}
  90. setup-trace-id: ${{ steps.setup.outputs.trace-id }}
  91. stale_lock_file_failed: ${{ steps.check-lock-file.outputs.stale_lock_file_failed == 'true' }}
  92. text: ${{ steps.sanitized.outputs.text }}
  93. title: ${{ steps.sanitized.outputs.title }}
  94. steps:
  95. - name: Setup Scripts
  96. id: setup
  97. uses: github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  98. with:
  99. destination: ${{ runner.temp }}/gh-aw/actions
  100. job-name: ${{ github.job }}
  101. safe-output-artifact-client: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }}
  102. env:
  103. GH_AW_SETUP_WORKFLOW_NAME: "PR Review Intent"
  104. GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/pr-review-intent.lock.yml@${{ github.ref }}
  105. GH_AW_INFO_VERSION: "0.137.0"
  106. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  107. GH_AW_INFO_ENGINE_ID: "codex"
  108. - name: Generate agentic run info
  109. id: generate_aw_info
  110. env:
  111. GH_AW_INFO_ENGINE_ID: "codex"
  112. GH_AW_INFO_ENGINE_NAME: "Codex"
  113. GH_AW_INFO_MODEL: "gpt-5.4"
  114. GH_AW_INFO_VERSION: "0.137.0"
  115. GH_AW_INFO_AGENT_VERSION: "0.137.0"
  116. GH_AW_INFO_CLI_VERSION: "v0.79.4"
  117. GH_AW_INFO_WORKFLOW_NAME: "PR Review Intent"
  118. GH_AW_INFO_EXPERIMENTAL: "false"
  119. GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true"
  120. GH_AW_INFO_STAGED: "false"
  121. GH_AW_INFO_ALLOWED_DOMAINS: '["ai-pixel.online","api-inference.modelscope.cn","api.commandcode.ai","api.deepseek.com","api.minimaxi.com","defaults","open.bigmodel.cn","opencode.ai"]'
  122. GH_AW_INFO_FIREWALL_ENABLED: "true"
  123. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  124. GH_AW_INFO_AWMG_VERSION: ""
  125. GH_AW_INFO_FIREWALL_TYPE: "squid"
  126. GH_AW_COMPILED_STRICT: "true"
  127. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  128. with:
  129. script: |
  130. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  131. setupGlobals(core, github, context, exec, io, getOctokit);
  132. const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_aw_info.cjs');
  133. await main(core, context);
  134. - name: Check daily workflow token guardrail
  135. id: daily-effective-workflow-guardrail
  136. if: ${{ env.GH_AW_MAX_DAILY_AI_CREDITS != '' }}
  137. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  138. env:
  139. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  140. GH_AW_WORKFLOW_ID: "pr-review-intent"
  141. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  142. GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT: ${{ github.event.inputs.aw_context || '' }}
  143. GH_AW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. GH_AW_MAX_DAILY_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }}
  145. with:
  146. github-token: ${{ secrets.GITHUB_TOKEN }}
  147. script: |
  148. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  149. setupGlobals(core, github, context, exec, io, getOctokit);
  150. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_daily_aic_workflow_guardrail.cjs');
  151. await main();
  152. - name: Validate CODEX_API_KEY or OPENAI_API_KEY secret
  153. id: validate-secret
  154. run: bash "${RUNNER_TEMP}/gh-aw/actions/validate_multi_secret.sh" CODEX_API_KEY OPENAI_API_KEY Codex https://github.github.com/gh-aw/reference/engines/#openai-codex
  155. env:
  156. CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
  157. OPENAI_API_KEY: ${{ secrets.PIXEL_API_KEY }}
  158. - name: Checkout .github and .agents folders
  159. uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
  160. with:
  161. persist-credentials: false
  162. sparse-checkout: |
  163. .github
  164. .agents
  165. .antigravity
  166. .claude
  167. .codex
  168. .crush
  169. .gemini
  170. .opencode
  171. .pi
  172. sparse-checkout-cone-mode: true
  173. fetch-depth: 1
  174. - name: Save agent config folders for base branch restoration
  175. env:
  176. GH_AW_AGENT_FOLDERS: ".agents .antigravity .claude .codex .crush .gemini .github .opencode .pi"
  177. GH_AW_AGENT_FILES: ".crush.json AGENTS.md ANTIGRAVITY.md CLAUDE.md GEMINI.md PI.md opencode.jsonc"
  178. # poutine:ignore untrusted_checkout_exec
  179. run: bash "${RUNNER_TEMP}/gh-aw/actions/save_base_github_folders.sh"
  180. - name: Check workflow lock file
  181. id: check-lock-file
  182. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  183. env:
  184. GH_AW_WORKFLOW_FILE: "pr-review-intent.lock.yml"
  185. GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}"
  186. with:
  187. script: |
  188. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  189. setupGlobals(core, github, context, exec, io, getOctokit);
  190. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_workflow_timestamp_api.cjs');
  191. await main();
  192. - name: Check compile-agentic version
  193. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  194. env:
  195. GH_AW_COMPILED_VERSION: "v0.79.4"
  196. with:
  197. script: |
  198. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  199. setupGlobals(core, github, context, exec, io, getOctokit);
  200. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_version_updates.cjs');
  201. await main();
  202. - name: Compute current body text
  203. id: sanitized
  204. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  205. env:
  206. GH_AW_ALLOWED_DOMAINS: "172.30.0.1,ai-pixel.online,api-inference.modelscope.cn,api.commandcode.ai,api.deepseek.com,api.minimaxi.com,api.openai.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,chatgpt.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,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.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,openai.com,opencode.ai,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,s.symcb.com,s.symcd.com,security.ubuntu.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com"
  207. with:
  208. script: |
  209. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  210. setupGlobals(core, github, context, exec, io, getOctokit);
  211. const { main } = require('${{ runner.temp }}/gh-aw/actions/compute_text.cjs');
  212. await main();
  213. - name: Create prompt with built-in context
  214. env:
  215. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  216. GH_AW_SAFE_OUTPUTS: ${{ runner.temp }}/gh-aw/safeoutputs/outputs.jsonl
  217. GH_AW_EXPR_1A3A194A: ${{ github.event.discussion.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'discussion' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  218. GH_AW_EXPR_463A214A: ${{ github.event.pull_request.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'pull_request' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  219. GH_AW_EXPR_802A9F6A: ${{ github.event.issue.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'issue' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  220. GH_AW_EXPR_FF1D34CE: ${{ github.event.comment.id || fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').comment_id }}
  221. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  222. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  223. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  224. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  225. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  226. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  227. GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
  228. GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
  229. # poutine:ignore untrusted_checkout_exec
  230. run: |
  231. bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh"
  232. {
  233. cat << 'GH_AW_PROMPT_4eff122a39649fc2_EOF'
  234. <system>
  235. GH_AW_PROMPT_4eff122a39649fc2_EOF
  236. cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md"
  237. cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md"
  238. cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md"
  239. cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md"
  240. cat << 'GH_AW_PROMPT_4eff122a39649fc2_EOF'
  241. <safe-output-tools>
  242. Tools: add_comment, missing_tool, missing_data, noop
  243. </safe-output-tools>
  244. GH_AW_PROMPT_4eff122a39649fc2_EOF
  245. cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md"
  246. cat << 'GH_AW_PROMPT_4eff122a39649fc2_EOF'
  247. <github-context>
  248. The following GitHub context information is available for this workflow:
  249. {{#if github.actor}}
  250. - **actor**: __GH_AW_GITHUB_ACTOR__
  251. {{/if}}
  252. {{#if github.repository}}
  253. - **repository**: __GH_AW_GITHUB_REPOSITORY__
  254. {{/if}}
  255. {{#if github.workspace}}
  256. - **workspace**: __GH_AW_GITHUB_WORKSPACE__
  257. {{/if}}
  258. {{#if github.event.issue.number || (github.aw.context.item_type == 'issue' && github.aw.context.item_number)}}
  259. - **issue-number**: #__GH_AW_EXPR_802A9F6A__
  260. {{/if}}
  261. {{#if github.event.discussion.number || (github.aw.context.item_type == 'discussion' && github.aw.context.item_number)}}
  262. - **discussion-number**: #__GH_AW_EXPR_1A3A194A__
  263. {{/if}}
  264. {{#if github.event.pull_request.number || (github.aw.context.item_type == 'pull_request' && github.aw.context.item_number)}}
  265. - **pull-request-number**: #__GH_AW_EXPR_463A214A__
  266. {{/if}}
  267. {{#if github.event.comment.id || github.aw.context.comment_id}}
  268. - **comment-id**: __GH_AW_EXPR_FF1D34CE__
  269. {{/if}}
  270. {{#if github.run_id}}
  271. - **workflow-run-id**: __GH_AW_GITHUB_RUN_ID__
  272. {{/if}}
  273. </github-context>
  274. GH_AW_PROMPT_4eff122a39649fc2_EOF
  275. cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md"
  276. cat << 'GH_AW_PROMPT_4eff122a39649fc2_EOF'
  277. </system>
  278. {{#runtime-import .github/workflows/shared/engine.md}}
  279. {{#runtime-import .github/workflows/shared/network.md}}
  280. {{#runtime-import .github/workflows/pr-review-intent.md}}
  281. GH_AW_PROMPT_4eff122a39649fc2_EOF
  282. } > "$GH_AW_PROMPT"
  283. - name: Interpolate variables and render templates
  284. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  285. env:
  286. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  287. GH_AW_ENGINE_ID: "codex"
  288. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  289. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  290. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  291. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  292. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  293. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  294. with:
  295. script: |
  296. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  297. setupGlobals(core, github, context, exec, io, getOctokit);
  298. const { main } = require('${{ runner.temp }}/gh-aw/actions/interpolate_prompt.cjs');
  299. await main();
  300. - name: Substitute placeholders
  301. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  302. env:
  303. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  304. GH_AW_EXPR_1A3A194A: ${{ github.event.discussion.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'discussion' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  305. GH_AW_EXPR_463A214A: ${{ github.event.pull_request.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'pull_request' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  306. GH_AW_EXPR_802A9F6A: ${{ github.event.issue.number || (fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_type == 'issue' && fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').item_number) }}
  307. GH_AW_EXPR_FF1D34CE: ${{ github.event.comment.id || fromJSON(github.event.inputs.aw_context || github.event.client_payload.aw_context || '{}').comment_id }}
  308. GH_AW_GITHUB_ACTOR: ${{ github.actor }}
  309. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
  310. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
  311. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
  312. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
  313. GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
  314. GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
  315. GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
  316. GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools'
  317. with:
  318. script: |
  319. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  320. setupGlobals(core, github, context, exec, io, getOctokit);
  321. const substitutePlaceholders = require('${{ runner.temp }}/gh-aw/actions/substitute_placeholders.cjs');
  322. // Call the substitution function
  323. return await substitutePlaceholders({
  324. file: process.env.GH_AW_PROMPT,
  325. substitutions: {
  326. GH_AW_EXPR_1A3A194A: process.env.GH_AW_EXPR_1A3A194A,
  327. GH_AW_EXPR_463A214A: process.env.GH_AW_EXPR_463A214A,
  328. GH_AW_EXPR_802A9F6A: process.env.GH_AW_EXPR_802A9F6A,
  329. GH_AW_EXPR_FF1D34CE: process.env.GH_AW_EXPR_FF1D34CE,
  330. GH_AW_GITHUB_ACTOR: process.env.GH_AW_GITHUB_ACTOR,
  331. GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_BASE_SHA,
  332. GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA,
  333. GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER,
  334. GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_TITLE,
  335. GH_AW_GITHUB_REPOSITORY: process.env.GH_AW_GITHUB_REPOSITORY,
  336. GH_AW_GITHUB_RUN_ID: process.env.GH_AW_GITHUB_RUN_ID,
  337. GH_AW_GITHUB_WORKSPACE: process.env.GH_AW_GITHUB_WORKSPACE,
  338. GH_AW_MCP_CLI_SERVERS_LIST: process.env.GH_AW_MCP_CLI_SERVERS_LIST
  339. }
  340. });
  341. - name: Validate prompt placeholders
  342. env:
  343. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  344. # poutine:ignore untrusted_checkout_exec
  345. run: bash "${RUNNER_TEMP}/gh-aw/actions/validate_prompt_placeholders.sh"
  346. - name: Print prompt
  347. env:
  348. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  349. # poutine:ignore untrusted_checkout_exec
  350. run: bash "${RUNNER_TEMP}/gh-aw/actions/print_prompt_summary.sh"
  351. - name: Upload activation artifact
  352. if: success()
  353. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  354. with:
  355. name: activation
  356. include-hidden-files: true
  357. path: |
  358. /tmp/gh-aw/aw_info.json
  359. /tmp/gh-aw/model_multipliers.json
  360. /tmp/gh-aw/models.json
  361. /tmp/gh-aw/aw-prompts/prompt.txt
  362. /tmp/gh-aw/aw-prompts/prompt-template.txt
  363. /tmp/gh-aw/aw-prompts/prompt-import-tree.json
  364. /tmp/gh-aw/github_rate_limits.jsonl
  365. /tmp/gh-aw/base
  366. /tmp/gh-aw/.codex/agents
  367. /tmp/gh-aw/.codex/skills
  368. if-no-files-found: ignore
  369. retention-days: 1
  370. agent:
  371. needs: activation
  372. if: needs.activation.outputs.daily_effective_workflow_exceeded != 'true'
  373. runs-on: ubuntu-latest
  374. permissions:
  375. checks: read
  376. contents: read
  377. issues: read
  378. pull-requests: read
  379. statuses: read
  380. env:
  381. DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
  382. GH_AW_ASSETS_ALLOWED_EXTS: ""
  383. GH_AW_ASSETS_BRANCH: ""
  384. GH_AW_ASSETS_MAX_SIZE_KB: 0
  385. GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs
  386. GH_AW_WORKFLOW_ID_SANITIZED: prreviewintent
  387. outputs:
  388. agentic_engine_timeout: ${{ steps.detect-agent-errors.outputs.agentic_engine_timeout || 'false' }}
  389. ai_credits_rate_limit_error: ${{ steps.parse-mcp-gateway.outputs.ai_credits_rate_limit_error || 'false' }}
  390. aic: ${{ steps.parse-mcp-gateway.outputs.aic }}
  391. ambient_context: ${{ steps.parse-mcp-gateway.outputs.ambient_context }}
  392. checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }}
  393. effective_tokens: ${{ steps.parse-mcp-gateway.outputs.effective_tokens }}
  394. has_patch: ${{ steps.collect_output.outputs.has_patch }}
  395. inference_access_error: ${{ steps.detect-agent-errors.outputs.inference_access_error || 'false' }}
  396. mcp_policy_error: ${{ steps.detect-agent-errors.outputs.mcp_policy_error || 'false' }}
  397. model: ${{ needs.activation.outputs.model }}
  398. model_not_supported_error: ${{ steps.detect-agent-errors.outputs.model_not_supported_error || 'false' }}
  399. output: ${{ steps.collect_output.outputs.output }}
  400. output_types: ${{ steps.collect_output.outputs.output_types }}
  401. setup-parent-span-id: ${{ steps.setup.outputs.parent-span-id || steps.setup.outputs.span-id }}
  402. setup-span-id: ${{ steps.setup.outputs.span-id }}
  403. setup-trace-id: ${{ steps.setup.outputs.trace-id }}
  404. steps:
  405. - name: Setup Scripts
  406. id: setup
  407. uses: github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  408. with:
  409. destination: ${{ runner.temp }}/gh-aw/actions
  410. job-name: ${{ github.job }}
  411. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  412. parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }}
  413. env:
  414. GH_AW_SETUP_WORKFLOW_NAME: "PR Review Intent"
  415. GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/pr-review-intent.lock.yml@${{ github.ref }}
  416. GH_AW_INFO_VERSION: "0.137.0"
  417. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  418. GH_AW_INFO_ENGINE_ID: "codex"
  419. - name: Set runtime paths
  420. id: set-runtime-paths
  421. run: |
  422. {
  423. echo "GH_AW_SAFE_OUTPUTS=${RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl"
  424. echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json"
  425. echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json"
  426. } >> "$GITHUB_OUTPUT"
  427. - name: Checkout repository
  428. uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
  429. with:
  430. persist-credentials: false
  431. - name: Create gh-aw temp directory
  432. run: bash "${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh"
  433. - name: Configure gh CLI for GitHub Enterprise
  434. run: bash "${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh"
  435. env:
  436. GH_TOKEN: ${{ github.token }}
  437. - name: Configure Git credentials
  438. env:
  439. REPO_NAME: ${{ github.repository }}
  440. SERVER_URL: ${{ github.server_url }}
  441. GITHUB_TOKEN: ${{ github.token }}
  442. run: |
  443. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  444. git config --global user.name "github-actions[bot]"
  445. git config --global am.keepcr true
  446. # Re-authenticate git with GitHub token
  447. SERVER_URL_STRIPPED="${SERVER_URL#https://}"
  448. git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
  449. echo "Git configured with standard GitHub Actions identity"
  450. - name: Checkout PR branch
  451. id: checkout-pr
  452. if: |
  453. github.event.pull_request || github.event.issue.pull_request || github.event_name == 'workflow_dispatch' && fromJSON(github.event.inputs.aw_context || '{}').item_type == 'pull_request'
  454. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  455. env:
  456. GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  457. with:
  458. github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  459. script: |
  460. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  461. setupGlobals(core, github, context, exec, io, getOctokit);
  462. const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs');
  463. await main();
  464. - name: Setup Node.js
  465. uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
  466. with:
  467. node-version: '24'
  468. package-manager-cache: false
  469. - name: Install Codex CLI
  470. run: npm install --ignore-scripts -g @openai/codex@0.137.0
  471. - name: Install AWF binary
  472. run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.27.0
  473. - name: Parse integrity filter lists
  474. id: parse-guard-vars
  475. env:
  476. GH_AW_BLOCKED_USERS_VAR: ${{ vars.GH_AW_GITHUB_BLOCKED_USERS || '' }}
  477. GH_AW_TRUSTED_USERS_VAR: ${{ vars.GH_AW_GITHUB_TRUSTED_USERS || '' }}
  478. GH_AW_APPROVAL_LABELS_VAR: ${{ vars.GH_AW_GITHUB_APPROVAL_LABELS || '' }}
  479. run: bash "${RUNNER_TEMP}/gh-aw/actions/parse_guard_list.sh"
  480. - name: Download activation artifact
  481. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  482. with:
  483. name: activation
  484. path: /tmp/gh-aw
  485. - name: Restore agent config folders from base branch
  486. if: steps.checkout-pr.outcome == 'success'
  487. env:
  488. GH_AW_AGENT_FOLDERS: ".agents .antigravity .claude .codex .crush .gemini .github .opencode .pi"
  489. GH_AW_AGENT_FILES: ".crush.json AGENTS.md ANTIGRAVITY.md CLAUDE.md GEMINI.md PI.md opencode.jsonc"
  490. run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_base_github_folders.sh"
  491. - name: Restore inline sub-agents from activation artifact
  492. env:
  493. GH_AW_SUB_AGENT_DIR: ".codex/agents"
  494. GH_AW_SUB_AGENT_EXT: ".md"
  495. run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_sub_agents.sh"
  496. - name: Restore inline skills from activation artifact
  497. env:
  498. GH_AW_SKILL_DIR: ".codex/skills"
  499. run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh"
  500. - name: Download container images
  501. run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.27.0 ghcr.io/github/gh-aw-firewall/api-proxy:0.27.0 ghcr.io/github/gh-aw-firewall/squid:0.27.0 ghcr.io/github/gh-aw-mcpg:v0.3.25@sha256:c10331ad17668ef89f38f5e356678788a40b0cd5fef96e8f92e1d9c1de47cbaa ghcr.io/github/github-mcp-server:v1.1.2@sha256:30197479d8036c7811892bc07e06f9a05c9ef3cdd79bc59f256d50647f95788c node:lts-alpine@sha256:2bdb65ed1dab192432bc31c95f94155ca5ad7fc1392fb7eb7526ab682fa5bf14
  502. - name: Generate Safe Outputs Config
  503. run: |
  504. mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
  505. mkdir -p /tmp/gh-aw/safeoutputs
  506. mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
  507. cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_7c6d636483f3c924_EOF'
  508. {"add_comment":{"max":1,"target":"triggering"},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"report_incomplete":{}}
  509. GH_AW_SAFE_OUTPUTS_CONFIG_7c6d636483f3c924_EOF
  510. - name: Generate Safe Outputs Tools
  511. env:
  512. GH_AW_TOOLS_META_JSON: |
  513. {
  514. "description_suffixes": {
  515. "add_comment": " CONSTRAINTS: Maximum 1 comment(s) can be added. Target: triggering. Supports reply_to_id for discussion threading."
  516. },
  517. "repo_params": {},
  518. "dynamic_tools": []
  519. }
  520. GH_AW_VALIDATION_JSON: |
  521. {
  522. "add_comment": {
  523. "defaultMax": 1,
  524. "fields": {
  525. "body": {
  526. "required": true,
  527. "type": "string",
  528. "sanitize": true,
  529. "maxLength": 65000
  530. },
  531. "item_number": {
  532. "issueOrPRNumber": true
  533. },
  534. "reply_to_id": {
  535. "type": "string",
  536. "maxLength": 256
  537. },
  538. "repo": {
  539. "type": "string",
  540. "maxLength": 256
  541. }
  542. }
  543. },
  544. "missing_data": {
  545. "defaultMax": 20,
  546. "fields": {
  547. "alternatives": {
  548. "type": "string",
  549. "sanitize": true,
  550. "maxLength": 256
  551. },
  552. "context": {
  553. "type": "string",
  554. "sanitize": true,
  555. "maxLength": 256
  556. },
  557. "data_type": {
  558. "type": "string",
  559. "sanitize": true,
  560. "maxLength": 128
  561. },
  562. "reason": {
  563. "type": "string",
  564. "sanitize": true,
  565. "maxLength": 256
  566. }
  567. }
  568. },
  569. "missing_tool": {
  570. "defaultMax": 20,
  571. "fields": {
  572. "alternatives": {
  573. "type": "string",
  574. "sanitize": true,
  575. "maxLength": 512
  576. },
  577. "reason": {
  578. "required": true,
  579. "type": "string",
  580. "sanitize": true,
  581. "maxLength": 256
  582. },
  583. "tool": {
  584. "type": "string",
  585. "sanitize": true,
  586. "maxLength": 128
  587. }
  588. }
  589. },
  590. "noop": {
  591. "defaultMax": 1,
  592. "fields": {
  593. "message": {
  594. "required": true,
  595. "type": "string",
  596. "sanitize": true,
  597. "maxLength": 65000
  598. }
  599. }
  600. },
  601. "report_incomplete": {
  602. "defaultMax": 5,
  603. "fields": {
  604. "details": {
  605. "type": "string",
  606. "sanitize": true,
  607. "maxLength": 65000
  608. },
  609. "reason": {
  610. "required": true,
  611. "type": "string",
  612. "sanitize": true,
  613. "maxLength": 1024
  614. }
  615. }
  616. }
  617. }
  618. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  619. with:
  620. script: |
  621. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  622. setupGlobals(core, github, context, exec, io, getOctokit);
  623. const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_safe_outputs_tools.cjs');
  624. await main();
  625. - name: Generate Safe Outputs MCP Server Config
  626. id: safe-outputs-config
  627. run: |
  628. # Generate a secure random API key (360 bits of entropy, 40+ chars)
  629. # Mask immediately to prevent timing vulnerabilities
  630. API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
  631. echo "::add-mask::${API_KEY}"
  632. PORT=3001
  633. # Set outputs for next steps
  634. {
  635. echo "safe_outputs_api_key=${API_KEY}"
  636. echo "safe_outputs_port=${PORT}"
  637. } >> "$GITHUB_OUTPUT"
  638. echo "Safe Outputs MCP server will run on port ${PORT}"
  639. - name: Start Safe Outputs MCP HTTP Server
  640. id: safe-outputs-start
  641. env:
  642. DEBUG: '*'
  643. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  644. GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-config.outputs.safe_outputs_port }}
  645. GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-config.outputs.safe_outputs_api_key }}
  646. GH_AW_SAFE_OUTPUTS_TOOLS_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/tools.json
  647. GH_AW_SAFE_OUTPUTS_CONFIG_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/config.json
  648. GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs
  649. run: |
  650. # Environment variables are set above to prevent template injection
  651. export DEBUG
  652. export GH_AW_SAFE_OUTPUTS
  653. export GH_AW_SAFE_OUTPUTS_PORT
  654. export GH_AW_SAFE_OUTPUTS_API_KEY
  655. export GH_AW_SAFE_OUTPUTS_TOOLS_PATH
  656. export GH_AW_SAFE_OUTPUTS_CONFIG_PATH
  657. export GH_AW_MCP_LOG_DIR
  658. bash "${RUNNER_TEMP}/gh-aw/actions/start_safe_outputs_server.sh"
  659. - name: Start MCP Gateway
  660. id: start-mcp-gateway
  661. env:
  662. CODEX_HOME: /tmp/gh-aw/mcp-config
  663. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  664. GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-start.outputs.api_key }}
  665. GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-start.outputs.port }}
  666. GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  667. run: |
  668. set -eo pipefail
  669. mkdir -p "${RUNNER_TEMP}/gh-aw/mcp-config"
  670. # Export gateway environment variables for MCP config and gateway script
  671. export MCP_GATEWAY_PORT="8080"
  672. export MCP_GATEWAY_DOMAIN="host.docker.internal"
  673. export MCP_GATEWAY_HOST_DOMAIN="localhost"
  674. MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
  675. echo "::add-mask::${MCP_GATEWAY_API_KEY}"
  676. export MCP_GATEWAY_API_KEY
  677. export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads"
  678. mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}"
  679. export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288"
  680. export DEBUG="*"
  681. export GH_AW_ENGINE="codex"
  682. MCP_GATEWAY_UID=$(id -u 2>/dev/null || echo '0')
  683. MCP_GATEWAY_GID=$(id -g 2>/dev/null || echo '0')
  684. case "${DOCKER_HOST:-}" in
  685. unix://* ) DOCKER_SOCK_PATH="${DOCKER_HOST#unix://}" ;;
  686. /* ) DOCKER_SOCK_PATH="$DOCKER_HOST" ;;
  687. * ) DOCKER_SOCK_PATH=/var/run/docker.sock ;;
  688. esac
  689. DOCKER_SOCK_GID=$(stat -c '%g' "$DOCKER_SOCK_PATH" 2>/dev/null || echo '0')
  690. export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host --add-host host.docker.internal:127.0.0.1 --user '"${MCP_GATEWAY_UID}"':'"${MCP_GATEWAY_GID}"' --group-add '"${DOCKER_SOCK_GID}"' -v '"${DOCKER_SOCK_PATH}"':/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 DOCKER_HOST=unix:///var/run/docker.sock -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 -e CODEX_HOME -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.3.25'
  691. cat > "${RUNNER_TEMP}/gh-aw/mcp-config/config.toml" << GH_AW_MCP_CONFIG_ea9931c32c5a8dca_EOF
  692. [history]
  693. persistence = "none"
  694. [shell_environment_policy]
  695. inherit = "core"
  696. include_only = ["^CODEX_API_KEY$", "^GH_AW_ASSETS_ALLOWED_EXTS$", "^GH_AW_ASSETS_BRANCH$", "^GH_AW_ASSETS_MAX_SIZE_KB$", "^GH_AW_SAFE_OUTPUTS$", "^GITHUB_PERSONAL_ACCESS_TOKEN$", "^GITHUB_REPOSITORY$", "^GITHUB_SERVER_URL$", "^HOME$", "^OPENAI_API_KEY$", "^PATH$"]
  697. [mcp_servers.github]
  698. user_agent = "pr-review-intent"
  699. startup_timeout_sec = 120
  700. tool_timeout_sec = 60
  701. container = "ghcr.io/github/github-mcp-server:v1.1.2"
  702. env = { "GITHUB_HOST" = "$GITHUB_SERVER_URL", "GITHUB_PERSONAL_ACCESS_TOKEN" = "$GH_AW_GITHUB_TOKEN", "GITHUB_READ_ONLY" = "1", "GITHUB_TOOLSETS" = "context,repos,issues,pull_requests" }
  703. env_vars = ["GITHUB_HOST", "GITHUB_PERSONAL_ACCESS_TOKEN", "GITHUB_READ_ONLY", "GITHUB_TOOLSETS"]
  704. [mcp_servers.safeoutputs]
  705. type = "http"
  706. url = "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT"
  707. [mcp_servers.safeoutputs.headers]
  708. Authorization = "$GH_AW_SAFE_OUTPUTS_API_KEY"
  709. [mcp_servers.safeoutputs."guard-policies"]
  710. [mcp_servers.safeoutputs."guard-policies".write-sink]
  711. accept = ["*"]
  712. GH_AW_MCP_CONFIG_ea9931c32c5a8dca_EOF
  713. # Generate JSON config for MCP gateway
  714. GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
  715. cat << GH_AW_MCP_CONFIG_ca772287f17ffc28_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
  716. {
  717. "mcpServers": {
  718. "github": {
  719. "container": "ghcr.io/github/github-mcp-server:v1.1.2",
  720. "env": {
  721. "GITHUB_HOST": "$GITHUB_SERVER_URL",
  722. "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_MCP_SERVER_TOKEN",
  723. "GITHUB_READ_ONLY": "1",
  724. "GITHUB_TOOLSETS": "context,repos,issues,pull_requests"
  725. },
  726. "guard-policies": {
  727. "allow-only": {
  728. "approval-labels": ${{ steps.parse-guard-vars.outputs.approval_labels }},
  729. "blocked-users": ${{ steps.parse-guard-vars.outputs.blocked_users }},
  730. "min-integrity": "none",
  731. "repos": "all",
  732. "trusted-users": ${{ steps.parse-guard-vars.outputs.trusted_users }}
  733. }
  734. }
  735. },
  736. "safeoutputs": {
  737. "type": "http",
  738. "url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT",
  739. "headers": {
  740. "Authorization": "$GH_AW_SAFE_OUTPUTS_API_KEY"
  741. },
  742. "guard-policies": {
  743. "write-sink": {
  744. "accept": [
  745. "*"
  746. ]
  747. }
  748. }
  749. }
  750. },
  751. "gateway": {
  752. "port": $MCP_GATEWAY_PORT,
  753. "domain": "${MCP_GATEWAY_DOMAIN}",
  754. "apiKey": "${MCP_GATEWAY_API_KEY}",
  755. "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}"
  756. }
  757. }
  758. GH_AW_MCP_CONFIG_ca772287f17ffc28_EOF
  759. # Sync converter output to writable CODEX_HOME for Codex
  760. mkdir -p /tmp/gh-aw/mcp-config
  761. cat > "/tmp/gh-aw/mcp-config/config.toml" << GH_AW_CODEX_SHELL_POLICY_929fca99db4cd5ec_EOF
  762. model_provider = "openai-proxy"
  763. [model_providers.openai-proxy]
  764. name = "OpenAI AWF proxy"
  765. base_url = "http://172.30.0.30:10000"
  766. env_key = "OPENAI_API_KEY"
  767. supports_websockets = false
  768. [shell_environment_policy]
  769. inherit = "core"
  770. include_only = ["^CODEX_API_KEY$", "^GH_AW_ASSETS_ALLOWED_EXTS$", "^GH_AW_ASSETS_BRANCH$", "^GH_AW_ASSETS_MAX_SIZE_KB$", "^GH_AW_SAFE_OUTPUTS$", "^GITHUB_PERSONAL_ACCESS_TOKEN$", "^GITHUB_REPOSITORY$", "^GITHUB_SERVER_URL$", "^HOME$", "^OPENAI_API_KEY$", "^PATH$"]
  771. GH_AW_CODEX_SHELL_POLICY_929fca99db4cd5ec_EOF
  772. awk '
  773. BEGIN { skip_openai_proxy = 0 }
  774. /^[[:space:]]*model_provider[[:space:]]*=/ { next }
  775. /^\[model_providers\.openai-proxy\][[:space:]]*$/ { skip_openai_proxy = 1; next }
  776. /^\[/ { skip_openai_proxy = 0 }
  777. !skip_openai_proxy { print }
  778. ' "${RUNNER_TEMP}/gh-aw/mcp-config/config.toml" >> "/tmp/gh-aw/mcp-config/config.toml"
  779. chmod 600 "/tmp/gh-aw/mcp-config/config.toml"
  780. mkdir -p "${CODEX_HOME}"
  781. if [ "/tmp/gh-aw/mcp-config/config.toml" != "${CODEX_HOME}/config.toml" ]; then cp "/tmp/gh-aw/mcp-config/config.toml" "${CODEX_HOME}/config.toml"; fi
  782. chmod 600 "${CODEX_HOME}/config.toml"
  783. - name: Mount MCP servers as CLIs
  784. id: mount-mcp-clis
  785. continue-on-error: true
  786. env:
  787. MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }}
  788. MCP_GATEWAY_DOMAIN: ${{ steps.start-mcp-gateway.outputs.gateway-domain }}
  789. MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }}
  790. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  791. with:
  792. script: |
  793. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  794. setupGlobals(core, github, context, exec, io);
  795. const { main } = require('${{ runner.temp }}/gh-aw/actions/mount_mcp_as_cli.cjs');
  796. await main();
  797. - name: Clean credentials
  798. continue-on-error: true
  799. run: bash "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh"
  800. - name: Audit pre-agent workspace
  801. id: pre_agent_audit
  802. continue-on-error: true
  803. run: bash "${RUNNER_TEMP}/gh-aw/actions/audit_pre_agent_workspace.sh"
  804. - name: Execute Codex CLI
  805. id: agentic_execution
  806. run: |
  807. set -o pipefail
  808. printf '%s' "$(date +%s%3N)" > /tmp/gh-aw/agent_cli_start_ms.txt
  809. mkdir -p "$CODEX_HOME/logs" && touch /tmp/gh-aw/agent-step-summary.md
  810. (umask 177 && touch /tmp/gh-aw/agent-stdio.log)
  811. GH_AW_MAX_AI_CREDITS="${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }}"
  812. printf '%s\n' "{\"\$schema\":\"https://github.com/github/gh-aw-firewall/releases/download/v0.27.0/awf-config.schema.json\",\"network\":{\"allowDomains\":[\"172.30.0.1\",\"ai-pixel.online\",\"api-inference.modelscope.cn\",\"api.commandcode.ai\",\"api.deepseek.com\",\"api.minimaxi.com\",\"api.openai.com\",\"api.snapcraft.io\",\"archive.ubuntu.com\",\"azure.archive.ubuntu.com\",\"chatgpt.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\",\"host.docker.internal\",\"json-schema.org\",\"json.schemastore.org\",\"keyserver.ubuntu.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\",\"openai.com\",\"opencode.ai\",\"packagecloud.io\",\"packages.cloud.google.com\",\"packages.microsoft.com\",\"ppa.launchpad.net\",\"s.symcb.com\",\"s.symcd.com\",\"security.ubuntu.com\",\"ts-crl.ws.symantec.com\",\"ts-ocsp.ws.symantec.com\",\"www.googleapis.com\"]},\"apiProxy\":{\"enabled\":true,\"enableTokenSteering\":true,\"maxRuns\":500,\"maxAiCredits\":${GH_AW_MAX_AI_CREDITS},\"targets\":{\"openai\":{\"host\":\"ai-pixel.online\"}},\"models\":{\"agent\":[\"sonnet-6x\",\"gpt-5.4\",\"gpt-5.3\",\"gemini-pro\",\"any\"],\"antigravity\":[\"copilot/antigravity*\",\"google/antigravity*\",\"gemini/antigravity*\"],\"any\":[\"copilot/*\",\"anthropic/*\",\"openai/*\",\"google/*\",\"gemini/*\"],\"claude\":[\"agent\"],\"codex\":[\"agent\"],\"coding\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\",\"gpt-5-codex\"],\"computer-use\":[\"copilot/*computer-use*\",\"google/*computer-use*\",\"gemini/*computer-use*\",\"openai/*computer-use*\"],\"copilot\":[\"agent\"],\"deep-research\":[\"copilot/deep-research*\",\"copilot/o3-deep-research*\",\"copilot/o4-mini-deep-research*\",\"google/deep-research*\",\"gemini/deep-research*\",\"openai/o3-deep-research*\",\"openai/o4-mini-deep-research*\"],\"gemini\":[\"agent\"],\"gemini-3-flash\":[\"copilot/gemini-3*flash*\",\"google/gemini-3*flash*\",\"gemini/gemini-3*flash*\"],\"gemini-3-pro\":[\"copilot/gemini-3*pro*\",\"google/gemini-3*pro*\",\"google/nano-banana*\",\"gemini/gemini-3*pro*\"],\"gemini-3.1-flash\":[\"copilot/gemini-3.1*flash*\",\"google/gemini-3.1*flash*\",\"gemini/gemini-3.1*flash*\"],\"gemini-3.1-pro\":[\"copilot/gemini-3.1*pro*\",\"google/gemini-3.1*pro*\",\"gemini/gemini-3.1*pro*\"],\"gemini-3.5-flash\":[\"copilot/gemini-3.5*flash*\",\"google/gemini-3.5*flash*\",\"gemini/gemini-3.5*flash*\"],\"gemini-flash\":[\"copilot/gemini-*flash*\",\"google/gemini-*flash*\",\"gemini/gemini-*flash*\"],\"gemini-flash-lite\":[\"copilot/gemini-*flash*lite*\",\"google/gemini-*flash*lite*\",\"gemini/gemini-*flash*lite*\"],\"gemini-pro\":[\"copilot/gemini-*pro*\",\"google/gemini-*pro*\",\"gemini/gemini-*pro*\"],\"gemma\":[\"copilot/gemma*\",\"google/gemma*\",\"gemini/gemma*\"],\"gpt-5\":[\"copilot/gpt-5*\",\"openai/gpt-5*\"],\"gpt-5-codex\":[\"copilot/gpt-5*codex*\",\"openai/gpt-5*codex*\"],\"gpt-5-mini\":[\"copilot/gpt-5*mini*\",\"openai/gpt-5*mini*\"],\"gpt-5-nano\":[\"copilot/gpt-5*nano*\",\"openai/gpt-5*nano*\"],\"gpt-5-pro\":[\"copilot/gpt-5*pro*\",\"openai/gpt-5*pro*\"],\"gpt-5.2\":[\"copilot/gpt-5.2*\",\"openai/gpt-5.2*\"],\"gpt-5.3\":[\"copilot/gpt-5.3*\",\"openai/gpt-5.3*\"],\"gpt-5.4\":[\"copilot/gpt-5.4*\",\"openai/gpt-5.4*\"],\"gpt-5.5\":[\"copilot/gpt-5.5*\",\"openai/gpt-5.5*\"],\"haiku\":[\"copilot/*haiku*\",\"anthropic/*haiku*\"],\"large\":[\"sonnet\",\"gpt-5-pro\",\"gpt-5\",\"gemini-pro\"],\"mai-code\":[\"copilot/MAI-Code*\",\"copilot/mai-code*\",\"openai/MAI-Code*\"],\"mini\":[\"haiku\",\"gpt-5-mini\",\"gpt-5-nano\",\"gemini-flash-lite\"],\"nano-banana\":[\"copilot/nano-banana*\",\"google/nano-banana*\",\"gemini/nano-banana*\"],\"opus\":[\"copilot/*opus*\",\"anthropic/*opus*\"],\"opusplan\":[\"opus?effort=high\"],\"reasoning\":[\"copilot/o1*\",\"copilot/o3*\",\"copilot/o4*\",\"openai/o1*\",\"openai/o3*\",\"openai/o4*\"],\"robotics\":[\"copilot/*robotics*\",\"google/*robotics*\",\"gemini/*robotics*\"],\"small\":[\"mini\"],\"small-agent\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash\"],\"sonnet\":[\"copilot/*sonnet*\",\"anthropic/*sonnet*\"],\"sonnet-6x\":[\"copilot/*sonnet-4.5*\",\"copilot/*sonnet-4.6*\",\"copilot/*sonnet-4-5-*\",\"anthropic/*sonnet-4-5-*\",\"copilot/*sonnet-4-6*\",\"anthropic/*sonnet-4-6*\"],\"summarization\":[\"haiku\",\"gpt-5-mini\",\"gemini-flash-lite\",\"mini\"],\"vision\":[\"copilot/gemini-*image*\",\"gemini/gemini-*image*\",\"copilot/gemini-*flash*\",\"gemini/gemini-*flash*\"]}},\"container\":{\"imageTag\":\"0.27.0\"}}" > "${RUNNER_TEMP}/gh-aw/awf-config.json"
  813. GH_AW_MODEL_MULTIPLIERS_PATH="/tmp/gh-aw/model_multipliers.json" node "${RUNNER_TEMP}/gh-aw/actions/merge_awf_model_multipliers.cjs"
  814. cp "${RUNNER_TEMP}/gh-aw/awf-config.json" /tmp/gh-aw/awf-config.json
  815. export GH_AW_MODELS_JSON_PATH="/tmp/gh-aw/models.json"
  816. GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS=""
  817. if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then
  818. GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="--docker-host-path-prefix /tmp/gh-aw"
  819. fi
  820. GH_AW_TOOL_CACHE_MOUNT=""
  821. GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}"
  822. if [ -d "$GH_AW_TOOL_CACHE" ]; then
  823. if [[ "$GH_AW_TOOL_CACHE" != /opt/* ]]; then
  824. GH_AW_TOOL_CACHE_MOUNT="$GH_AW_TOOL_CACHE:$GH_AW_TOOL_CACHE:ro"
  825. fi
  826. elif [ -d "/home/runner/work/_tool" ]; then
  827. GH_AW_TOOL_CACHE_MOUNT="/home/runner/work/_tool:/home/runner/work/_tool:ro"
  828. fi
  829. # shellcheck disable=SC1003
  830. sudo -E awf --config "${RUNNER_TEMP}/gh-aw/awf-config.json" --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" ${GH_AW_TOOL_CACHE_MOUNT:+--mount "$GH_AW_TOOL_CACHE_MOUNT"} ${GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS} --env-all --exclude-env CODEX_API_KEY --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --exclude-env OPENAI_API_KEY --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --allow-host-ports 80,443,8080 --skip-pull \
  831. -- /bin/bash -c 'set +o histexpand; export PATH="${RUNNER_TEMP}/gh-aw/mcp-cli/bin:$PATH" && GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}"; export PATH="$(find "$GH_AW_TOOL_CACHE" /opt/hostedtoolcache /home/runner/work/_tool -maxdepth 5 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && GH_AW_NODE_EXEC="${GH_AW_NODE_BIN:-}"; if [ -z "$GH_AW_NODE_EXEC" ] || [ ! -x "$GH_AW_NODE_EXEC" ]; then GH_AW_NODE_EXEC="$(command -v node 2>/dev/null || true)"; fi; if [ -z "$GH_AW_NODE_EXEC" ]; then echo "node runtime missing on this runner — check runtimes.node in workflow YAML" >&2; exit 127; fi; GH_AW_NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"; if [ -n "$GH_AW_NPM_GLOBAL_ROOT" ]; then export NODE_PATH="${GH_AW_NPM_GLOBAL_ROOT}${NODE_PATH:+:${NODE_PATH}}"; fi; "$GH_AW_NODE_EXEC" ${RUNNER_TEMP}/gh-aw/actions/codex_harness.cjs codex exec${GH_AW_MODEL_AGENT_CODEX:+ --model "$GH_AW_MODEL_AGENT_CODEX"} -c web_search="disabled" -c fetch="disabled" --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log
  832. env:
  833. CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
  834. CODEX_HOME: /tmp/gh-aw/mcp-config
  835. GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
  836. GH_AW_MCP_CONFIG: ${{ runner.temp }}/gh-aw/mcp-config/config.toml
  837. GH_AW_MODEL_AGENT_CODEX: gpt-5.4
  838. GH_AW_PHASE: agent
  839. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  840. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  841. GH_AW_VERSION: v0.79.4
  842. GITHUB_AW: true
  843. GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md
  844. GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
  845. GIT_AUTHOR_NAME: github-actions[bot]
  846. GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
  847. GIT_COMMITTER_NAME: github-actions[bot]
  848. OPENAI_API_KEY: ${{ secrets.PIXEL_API_KEY }}
  849. OPENAI_BASE_URL: https://ai-pixel.online
  850. RUNNER_TEMP: ${{ runner.temp }}
  851. RUST_LOG: ${{ runner.debug == 1 && 'trace,hyper_util=info,mio=info,reqwest=info,os_info=info,codex_otel=warn,codex_core=debug,ocodex_exec=debug' || 'warn' }}
  852. - name: Detect agent errors
  853. if: always()
  854. id: detect-agent-errors
  855. continue-on-error: true
  856. run: node "${RUNNER_TEMP}/gh-aw/actions/detect_agent_errors.cjs"
  857. - name: Configure Git credentials
  858. env:
  859. REPO_NAME: ${{ github.repository }}
  860. SERVER_URL: ${{ github.server_url }}
  861. GITHUB_TOKEN: ${{ github.token }}
  862. run: |
  863. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  864. git config --global user.name "github-actions[bot]"
  865. git config --global am.keepcr true
  866. # Re-authenticate git with GitHub token
  867. SERVER_URL_STRIPPED="${SERVER_URL#https://}"
  868. git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
  869. echo "Git configured with standard GitHub Actions identity"
  870. - name: Stop MCP Gateway
  871. if: always()
  872. continue-on-error: true
  873. env:
  874. MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }}
  875. MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }}
  876. GATEWAY_PID: ${{ steps.start-mcp-gateway.outputs.gateway-pid }}
  877. run: |
  878. bash "${RUNNER_TEMP}/gh-aw/actions/stop_mcp_gateway.sh" "$GATEWAY_PID"
  879. - name: Redact secrets in logs
  880. if: always()
  881. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  882. with:
  883. script: |
  884. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  885. setupGlobals(core, github, context, exec, io, getOctokit);
  886. const { main } = require('${{ runner.temp }}/gh-aw/actions/redact_secrets.cjs');
  887. await main();
  888. env:
  889. GH_AW_SECRET_NAMES: 'CODEX_API_KEY,GH_AW_GITHUB_MCP_SERVER_TOKEN,GH_AW_GITHUB_TOKEN,GITHUB_TOKEN,OPENAI_API_KEY,PIXEL_API_KEY'
  890. SECRET_CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
  891. SECRET_GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }}
  892. SECRET_GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }}
  893. SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  894. SECRET_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  895. SECRET_PIXEL_API_KEY: ${{ secrets.PIXEL_API_KEY }}
  896. - name: Append agent step summary
  897. if: always()
  898. run: bash "${RUNNER_TEMP}/gh-aw/actions/append_agent_step_summary.sh"
  899. - name: Copy Safe Outputs
  900. if: always()
  901. env:
  902. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  903. run: |
  904. mkdir -p /tmp/gh-aw
  905. cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true
  906. - name: Ingest agent output
  907. id: collect_output
  908. if: always()
  909. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  910. env:
  911. GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
  912. GH_AW_ALLOWED_DOMAINS: "172.30.0.1,ai-pixel.online,api-inference.modelscope.cn,api.commandcode.ai,api.deepseek.com,api.minimaxi.com,api.openai.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,chatgpt.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,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.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,openai.com,opencode.ai,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,s.symcb.com,s.symcd.com,security.ubuntu.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com"
  913. GITHUB_SERVER_URL: ${{ github.server_url }}
  914. GITHUB_API_URL: ${{ github.api_url }}
  915. with:
  916. script: |
  917. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  918. setupGlobals(core, github, context, exec, io, getOctokit);
  919. const { main } = require('${{ runner.temp }}/gh-aw/actions/collect_ndjson_output.cjs');
  920. await main();
  921. - name: Parse agent logs for step summary
  922. if: always()
  923. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  924. env:
  925. GH_AW_AGENT_OUTPUT: /tmp/gh-aw/agent-stdio.log
  926. with:
  927. script: |
  928. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  929. setupGlobals(core, github, context, exec, io, getOctokit);
  930. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_codex_log.cjs');
  931. await main();
  932. - name: Parse MCP Gateway logs for step summary
  933. if: always()
  934. id: parse-mcp-gateway
  935. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  936. with:
  937. script: |
  938. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  939. setupGlobals(core, github, context, exec, io, getOctokit);
  940. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_mcp_gateway_log.cjs');
  941. await main();
  942. - name: Print firewall logs
  943. if: always()
  944. continue-on-error: true
  945. env:
  946. AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
  947. run: |
  948. # Fix permissions on firewall logs/audit dirs so they can be uploaded as artifacts
  949. # AWF runs with sudo, creating files owned by root
  950. sudo chmod -R a+rX /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
  951. # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step)
  952. if command -v awf &> /dev/null; then
  953. awf logs summary | tee -a "$GITHUB_STEP_SUMMARY"
  954. else
  955. echo 'AWF binary not installed, skipping firewall log summary'
  956. fi
  957. - name: Parse token usage for step summary
  958. if: always()
  959. continue-on-error: true
  960. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  961. with:
  962. script: |
  963. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  964. setupGlobals(core, github, context, exec, io, getOctokit);
  965. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_token_usage.cjs');
  966. await main();
  967. - name: Print AWF reflect summary
  968. if: always()
  969. continue-on-error: true
  970. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  971. with:
  972. script: |
  973. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  974. setupGlobals(core, github, context, exec, io, getOctokit);
  975. const { main } = require('${{ runner.temp }}/gh-aw/actions/awf_reflect_summary.cjs');
  976. await main();
  977. - name: Write agent output placeholder if missing
  978. if: always()
  979. run: |
  980. if [ ! -f /tmp/gh-aw/agent_output.json ]; then
  981. echo '{"items":[]}' > /tmp/gh-aw/agent_output.json
  982. fi
  983. - name: Upload agent artifacts
  984. if: always()
  985. continue-on-error: true
  986. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  987. with:
  988. name: agent
  989. path: |
  990. /tmp/gh-aw/aw-prompts/prompt.txt
  991. /tmp/gh-aw/mcp-config/logs/
  992. /tmp/gh-aw/redacted-urls.log
  993. /tmp/gh-aw/mcp-logs/
  994. /tmp/gh-aw/proxy-logs/
  995. !/tmp/gh-aw/proxy-logs/proxy-tls/
  996. /tmp/gh-aw/agent_usage.json
  997. /tmp/gh-aw/agent-stdio.log
  998. /tmp/gh-aw/pre-agent-audit.txt
  999. /tmp/gh-aw/agent/
  1000. /tmp/gh-aw/github_rate_limits.jsonl
  1001. /tmp/gh-aw/safeoutputs.jsonl
  1002. /tmp/gh-aw/agent_output.json
  1003. /tmp/gh-aw/aw-*.patch
  1004. /tmp/gh-aw/aw-*.bundle
  1005. /tmp/gh-aw/awf-config.json
  1006. /tmp/gh-aw/sandbox/firewall/logs/
  1007. /tmp/gh-aw/sandbox/firewall/audit/
  1008. /tmp/gh-aw/sandbox/firewall/awf-reflect.json
  1009. if-no-files-found: ignore
  1010. conclusion:
  1011. needs:
  1012. - activation
  1013. - agent
  1014. - detection
  1015. - safe_outputs
  1016. if: >
  1017. always() && (needs.agent.result != 'skipped' || needs.activation.outputs.lockdown_check_failed == 'true' ||
  1018. needs.activation.outputs.stale_lock_file_failed == 'true' || needs.activation.outputs.daily_effective_workflow_exceeded == 'true')
  1019. runs-on: ubuntu-slim
  1020. permissions:
  1021. contents: read
  1022. discussions: write
  1023. issues: write
  1024. pull-requests: write
  1025. concurrency:
  1026. group: "gh-aw-conclusion-pr-review-intent"
  1027. cancel-in-progress: false
  1028. queue: max
  1029. outputs:
  1030. incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }}
  1031. noop_message: ${{ steps.noop.outputs.noop_message }}
  1032. tools_reported: ${{ steps.missing_tool.outputs.tools_reported }}
  1033. total_count: ${{ steps.missing_tool.outputs.total_count }}
  1034. steps:
  1035. - name: Setup Scripts
  1036. id: setup
  1037. uses: github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  1038. with:
  1039. destination: ${{ runner.temp }}/gh-aw/actions
  1040. job-name: ${{ github.job }}
  1041. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  1042. parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }}
  1043. env:
  1044. GH_AW_SETUP_WORKFLOW_NAME: "PR Review Intent"
  1045. GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/pr-review-intent.lock.yml@${{ github.ref }}
  1046. GH_AW_INFO_VERSION: "0.137.0"
  1047. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  1048. GH_AW_INFO_ENGINE_ID: "codex"
  1049. - name: Download agent output artifact
  1050. id: download-agent-output
  1051. continue-on-error: true
  1052. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  1053. with:
  1054. name: agent
  1055. path: /tmp/gh-aw/
  1056. - name: Setup agent output environment variable
  1057. id: setup-agent-output-env
  1058. if: steps.download-agent-output.outcome == 'success'
  1059. run: |
  1060. mkdir -p /tmp/gh-aw/
  1061. find "/tmp/gh-aw/" -type f -print
  1062. echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT"
  1063. - name: Collect usage artifact files
  1064. if: always()
  1065. continue-on-error: true
  1066. run: |
  1067. mkdir -p /tmp/gh-aw/usage/agent /tmp/gh-aw/usage/detection
  1068. echo "Usage artifact source file status:"
  1069. for file in /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/detection_usage.jsonl /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl; do
  1070. [ -f "$file" ] && echo "FOUND: $file" || echo "MISSING: $file"
  1071. done
  1072. [ -f /tmp/gh-aw/aw-info.jsonl ] && cp /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/usage/aw-info.jsonl || true
  1073. [ -f /tmp/gh-aw/agent_usage.jsonl ] && cp /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/usage/agent_usage.jsonl || true
  1074. [ -f /tmp/gh-aw/detection_usage.jsonl ] && cp /tmp/gh-aw/detection_usage.jsonl /tmp/gh-aw/usage/detection_usage.jsonl || true
  1075. [ -f /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true
  1076. [ -f /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true
  1077. [ -f /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/agent/token_usage.jsonl || true
  1078. [ -f /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall-audit-logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true
  1079. [ -f /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true
  1080. [ -f /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl ] && cp /tmp/gh-aw/threat-detection/sandbox/firewall/audit/api-proxy-logs/token-usage.jsonl /tmp/gh-aw/usage/detection/token_usage.jsonl || true
  1081. [ -f /tmp/gh-aw/usage/agent/token_usage.jsonl ] || : > /tmp/gh-aw/usage/agent/token_usage.jsonl
  1082. [ -f /tmp/gh-aw/usage/detection/token_usage.jsonl ] || : > /tmp/gh-aw/usage/detection/token_usage.jsonl
  1083. find /tmp/gh-aw/usage -type f -print | sort
  1084. - name: Upload usage artifact
  1085. if: always()
  1086. continue-on-error: true
  1087. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  1088. with:
  1089. name: usage
  1090. path: |
  1091. /tmp/gh-aw/usage/aw-info.jsonl
  1092. /tmp/gh-aw/usage/agent_usage.jsonl
  1093. /tmp/gh-aw/usage/detection_usage.jsonl
  1094. /tmp/gh-aw/usage/agent/token_usage.jsonl
  1095. /tmp/gh-aw/usage/detection/token_usage.jsonl
  1096. if-no-files-found: ignore
  1097. - name: Process no-op messages
  1098. id: noop
  1099. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1100. env:
  1101. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1102. GH_AW_NOOP_MAX: "1"
  1103. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1104. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1105. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  1106. GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }}
  1107. GH_AW_NOOP_REPORT_AS_ISSUE: "true"
  1108. GH_AW_AIC: ${{ needs.agent.outputs.aic }}
  1109. GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }}
  1110. GH_AW_AMBIENT_CONTEXT: ${{ needs.agent.outputs.ambient_context }}
  1111. GH_AW_WORKFLOW_ID: "pr-review-intent"
  1112. with:
  1113. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1114. script: |
  1115. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1116. setupGlobals(core, github, context, exec, io, getOctokit);
  1117. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_noop_message.cjs');
  1118. await main();
  1119. - name: Log detection run
  1120. id: detection_runs
  1121. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1122. env:
  1123. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1124. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1125. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1126. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  1127. GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }}
  1128. GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }}
  1129. with:
  1130. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1131. script: |
  1132. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1133. setupGlobals(core, github, context, exec, io, getOctokit);
  1134. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_detection_runs.cjs');
  1135. await main();
  1136. - name: Record missing tool
  1137. id: missing_tool
  1138. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1139. env:
  1140. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1141. GH_AW_MISSING_TOOL_CREATE_ISSUE: "true"
  1142. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1143. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1144. with:
  1145. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1146. script: |
  1147. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1148. setupGlobals(core, github, context, exec, io, getOctokit);
  1149. const { main } = require('${{ runner.temp }}/gh-aw/actions/missing_tool.cjs');
  1150. await main();
  1151. - name: Record incomplete
  1152. id: report_incomplete
  1153. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1154. env:
  1155. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1156. GH_AW_REPORT_INCOMPLETE_CREATE_ISSUE: "true"
  1157. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1158. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1159. with:
  1160. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1161. script: |
  1162. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1163. setupGlobals(core, github, context, exec, io, getOctokit);
  1164. const { main } = require('${{ runner.temp }}/gh-aw/actions/report_incomplete_handler.cjs');
  1165. await main();
  1166. - name: Handle agent failure
  1167. id: handle_agent_failure
  1168. if: always()
  1169. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1170. env:
  1171. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1172. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1173. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1174. GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  1175. GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }}
  1176. GH_AW_WORKFLOW_ID: "pr-review-intent"
  1177. GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168"
  1178. GH_AW_ENGINE_ID: "codex"
  1179. GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }}
  1180. GH_AW_CHECKOUT_PR_SUCCESS: ${{ needs.agent.outputs.checkout_pr_success }}
  1181. GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens || '' }}
  1182. GH_AW_AI_CREDITS_RATE_LIMIT_ERROR: ${{ needs.agent.outputs.ai_credits_rate_limit_error || 'false' }}
  1183. GH_AW_AIC: ${{ needs.agent.outputs.aic }}
  1184. GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }}
  1185. GH_AW_INFERENCE_ACCESS_ERROR: ${{ needs.agent.outputs.inference_access_error }}
  1186. GH_AW_MCP_POLICY_ERROR: ${{ needs.agent.outputs.mcp_policy_error }}
  1187. GH_AW_AGENTIC_ENGINE_TIMEOUT: ${{ needs.agent.outputs.agentic_engine_timeout }}
  1188. GH_AW_MODEL_NOT_SUPPORTED_ERROR: ${{ needs.agent.outputs.model_not_supported_error }}
  1189. GH_AW_ENGINE_API_HOSTS: "api.openai.com"
  1190. GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }}
  1191. GH_AW_STALE_LOCK_FILE_FAILED: ${{ needs.activation.outputs.stale_lock_file_failed }}
  1192. GH_AW_DAILY_EFFECTIVE_WORKFLOW_EXCEEDED: ${{ needs.activation.outputs.daily_effective_workflow_exceeded }}
  1193. GH_AW_DAILY_EFFECTIVE_WORKFLOW_TOTAL_EFFECTIVE_TOKENS: ${{ needs.activation.outputs.daily_effective_workflow_total_effective_tokens }}
  1194. GH_AW_DAILY_EFFECTIVE_WORKFLOW_THRESHOLD: ${{ needs.activation.outputs.daily_effective_workflow_threshold }}
  1195. GH_AW_GROUP_REPORTS: "false"
  1196. GH_AW_FAILURE_REPORT_AS_ISSUE: "true"
  1197. GH_AW_MISSING_TOOL_REPORT_AS_FAILURE: "true"
  1198. GH_AW_MISSING_DATA_REPORT_AS_FAILURE: "true"
  1199. GH_AW_TIMEOUT_MINUTES: "15"
  1200. with:
  1201. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1202. script: |
  1203. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1204. setupGlobals(core, github, context, exec, io, getOctokit);
  1205. const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_agent_failure.cjs');
  1206. await main();
  1207. detection:
  1208. needs:
  1209. - activation
  1210. - agent
  1211. if: >
  1212. always() && needs.agent.result != 'skipped' && (needs.agent.outputs.output_types != '' || needs.agent.outputs.has_patch == 'true')
  1213. runs-on: ubuntu-latest
  1214. permissions:
  1215. contents: read
  1216. outputs:
  1217. aic: ${{ steps.parse_detection_token_usage.outputs.aic }}
  1218. detection_conclusion: ${{ steps.detection_conclusion.outputs.conclusion }}
  1219. detection_reason: ${{ steps.detection_conclusion.outputs.reason }}
  1220. detection_success: ${{ steps.detection_conclusion.outputs.success }}
  1221. steps:
  1222. - name: Setup Scripts
  1223. id: setup
  1224. uses: github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  1225. with:
  1226. destination: ${{ runner.temp }}/gh-aw/actions
  1227. job-name: ${{ github.job }}
  1228. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  1229. parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }}
  1230. env:
  1231. GH_AW_SETUP_WORKFLOW_NAME: "PR Review Intent"
  1232. GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/pr-review-intent.lock.yml@${{ github.ref }}
  1233. GH_AW_INFO_VERSION: "0.137.0"
  1234. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  1235. GH_AW_INFO_ENGINE_ID: "codex"
  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: Checkout repository for patch context
  1251. if: needs.agent.outputs.has_patch == 'true'
  1252. uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
  1253. with:
  1254. persist-credentials: false
  1255. # --- Threat Detection ---
  1256. - name: Clean stale firewall files from agent artifact
  1257. run: |
  1258. rm -rf /tmp/gh-aw/sandbox/firewall/logs
  1259. rm -rf /tmp/gh-aw/sandbox/firewall/audit
  1260. - name: Check if detection needed
  1261. id: detection_guard
  1262. if: always()
  1263. env:
  1264. OUTPUT_TYPES: ${{ needs.agent.outputs.output_types }}
  1265. HAS_PATCH: ${{ needs.agent.outputs.has_patch }}
  1266. run: |
  1267. if [[ -n "$OUTPUT_TYPES" || "$HAS_PATCH" == "true" ]]; then
  1268. echo "run_detection=true" >> "$GITHUB_OUTPUT"
  1269. echo "Detection will run: output_types=$OUTPUT_TYPES, has_patch=$HAS_PATCH"
  1270. else
  1271. echo "run_detection=false" >> "$GITHUB_OUTPUT"
  1272. echo "Detection skipped: no agent outputs or patches to analyze"
  1273. fi
  1274. - name: Clear MCP Config for detection
  1275. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1276. run: |
  1277. rm -f "${RUNNER_TEMP}/gh-aw/mcp-config/mcp-servers.json"
  1278. rm -f /home/runner/.copilot/mcp-config.json
  1279. rm -f "$GITHUB_WORKSPACE/.gemini/settings.json"
  1280. - name: Prepare threat detection files
  1281. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1282. run: |
  1283. mkdir -p /tmp/gh-aw/threat-detection/aw-prompts
  1284. rm -f /tmp/gh-aw/agent_usage.json
  1285. cp /tmp/gh-aw/aw-prompts/prompt.txt /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt 2>/dev/null || true
  1286. if [ ! -s /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt ]; then
  1287. echo "::warning::ERR_VALIDATION: Missing or empty detection context prompt at /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt. Ensure the agent artifact includes /tmp/gh-aw/aw-prompts/prompt.txt. Detection will continue with fallback workflow context."
  1288. fi
  1289. cp /tmp/gh-aw/agent_output.json /tmp/gh-aw/threat-detection/agent_output.json 2>/dev/null || true
  1290. for f in /tmp/gh-aw/aw-*.patch; do
  1291. [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1292. done
  1293. for f in /tmp/gh-aw/aw-*.bundle; do
  1294. [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1295. done
  1296. echo "Prepared threat detection files:"
  1297. ls -la /tmp/gh-aw/threat-detection/ 2>/dev/null || true
  1298. - name: Setup threat detection
  1299. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1300. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1301. env:
  1302. WORKFLOW_NAME: "PR Review Intent"
  1303. WORKFLOW_DESCRIPTION: "自动审计 Pull Request 的代码意图、隐含约束、实现对齐情况与发布风险"
  1304. HAS_PATCH: ${{ needs.agent.outputs.has_patch }}
  1305. with:
  1306. script: |
  1307. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1308. setupGlobals(core, github, context, exec, io, getOctokit);
  1309. const { main } = require('${{ runner.temp }}/gh-aw/actions/setup_threat_detection.cjs');
  1310. await main();
  1311. - name: Ensure threat-detection directory and log
  1312. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1313. run: |
  1314. mkdir -p /tmp/gh-aw/threat-detection
  1315. touch /tmp/gh-aw/threat-detection/detection.log
  1316. - name: Setup Node.js
  1317. uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
  1318. with:
  1319. node-version: '24'
  1320. package-manager-cache: false
  1321. - name: Install Codex CLI
  1322. run: npm install --ignore-scripts -g @openai/codex@0.137.0
  1323. - name: Install AWF binary
  1324. run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.27.0
  1325. - name: Download container images
  1326. run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-firewall/agent:0.27.0 ghcr.io/github/gh-aw-firewall/api-proxy:0.27.0 ghcr.io/github/gh-aw-firewall/squid:0.27.0 ghcr.io/github/gh-aw-mcpg:v0.3.25@sha256:c10331ad17668ef89f38f5e356678788a40b0cd5fef96e8f92e1d9c1de47cbaa
  1327. - name: Start MCP Gateway
  1328. id: start-mcp-gateway
  1329. env:
  1330. CODEX_HOME: /tmp/gh-aw/mcp-config
  1331. run: |
  1332. set -eo pipefail
  1333. mkdir -p "${RUNNER_TEMP}/gh-aw/mcp-config"
  1334. # Export gateway environment variables for MCP config and gateway script
  1335. export MCP_GATEWAY_PORT="8080"
  1336. export MCP_GATEWAY_DOMAIN="host.docker.internal"
  1337. export MCP_GATEWAY_HOST_DOMAIN="localhost"
  1338. MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
  1339. echo "::add-mask::${MCP_GATEWAY_API_KEY}"
  1340. export MCP_GATEWAY_API_KEY
  1341. export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads"
  1342. mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}"
  1343. export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288"
  1344. export DEBUG="*"
  1345. export GH_AW_ENGINE="codex"
  1346. MCP_GATEWAY_UID=$(id -u 2>/dev/null || echo '0')
  1347. MCP_GATEWAY_GID=$(id -g 2>/dev/null || echo '0')
  1348. case "${DOCKER_HOST:-}" in
  1349. unix://* ) DOCKER_SOCK_PATH="${DOCKER_HOST#unix://}" ;;
  1350. /* ) DOCKER_SOCK_PATH="$DOCKER_HOST" ;;
  1351. * ) DOCKER_SOCK_PATH=/var/run/docker.sock ;;
  1352. esac
  1353. DOCKER_SOCK_GID=$(stat -c '%g' "$DOCKER_SOCK_PATH" 2>/dev/null || echo '0')
  1354. export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host --add-host host.docker.internal:127.0.0.1 --user '"${MCP_GATEWAY_UID}"':'"${MCP_GATEWAY_GID}"' --group-add '"${DOCKER_SOCK_GID}"' -v '"${DOCKER_SOCK_PATH}"':/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 DOCKER_HOST=unix:///var/run/docker.sock -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 CODEX_HOME -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.3.25'
  1355. cat > "${RUNNER_TEMP}/gh-aw/mcp-config/config.toml" << GH_AW_MCP_CONFIG_9dc1744e356f5fbe_EOF
  1356. [history]
  1357. persistence = "none"
  1358. [shell_environment_policy]
  1359. inherit = "core"
  1360. include_only = ["^CODEX_API_KEY$", "^HOME$", "^OPENAI_API_KEY$", "^PATH$"]
  1361. GH_AW_MCP_CONFIG_9dc1744e356f5fbe_EOF
  1362. # Generate JSON config for MCP gateway
  1363. GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
  1364. cat << GH_AW_MCP_CONFIG_37834a58b4c29838_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
  1365. {
  1366. "mcpServers": {
  1367. },
  1368. "gateway": {
  1369. "port": $MCP_GATEWAY_PORT,
  1370. "domain": "${MCP_GATEWAY_DOMAIN}",
  1371. "apiKey": "${MCP_GATEWAY_API_KEY}",
  1372. "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}"
  1373. }
  1374. }
  1375. GH_AW_MCP_CONFIG_37834a58b4c29838_EOF
  1376. # Sync converter output to writable CODEX_HOME for Codex
  1377. mkdir -p /tmp/gh-aw/mcp-config
  1378. cat > "/tmp/gh-aw/mcp-config/config.toml" << GH_AW_CODEX_SHELL_POLICY_cb4a4f0f8e96eaf4_EOF
  1379. model_provider = "openai-proxy"
  1380. [model_providers.openai-proxy]
  1381. name = "OpenAI AWF proxy"
  1382. base_url = "http://172.30.0.30:10000"
  1383. env_key = "OPENAI_API_KEY"
  1384. supports_websockets = false
  1385. [shell_environment_policy]
  1386. inherit = "core"
  1387. include_only = ["^CODEX_API_KEY$", "^HOME$", "^OPENAI_API_KEY$", "^PATH$"]
  1388. GH_AW_CODEX_SHELL_POLICY_cb4a4f0f8e96eaf4_EOF
  1389. awk '
  1390. BEGIN { skip_openai_proxy = 0 }
  1391. /^[[:space:]]*model_provider[[:space:]]*=/ { next }
  1392. /^\[model_providers\.openai-proxy\][[:space:]]*$/ { skip_openai_proxy = 1; next }
  1393. /^\[/ { skip_openai_proxy = 0 }
  1394. !skip_openai_proxy { print }
  1395. ' "${RUNNER_TEMP}/gh-aw/mcp-config/config.toml" >> "/tmp/gh-aw/mcp-config/config.toml"
  1396. chmod 600 "/tmp/gh-aw/mcp-config/config.toml"
  1397. mkdir -p "${CODEX_HOME}"
  1398. if [ "/tmp/gh-aw/mcp-config/config.toml" != "${CODEX_HOME}/config.toml" ]; then cp "/tmp/gh-aw/mcp-config/config.toml" "${CODEX_HOME}/config.toml"; fi
  1399. chmod 600 "${CODEX_HOME}/config.toml"
  1400. - name: Execute Codex CLI
  1401. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1402. continue-on-error: true
  1403. id: detection_agentic_execution
  1404. run: |
  1405. set -o pipefail
  1406. printf '%s' "$(date +%s%3N)" > /tmp/gh-aw/agent_cli_start_ms.txt
  1407. mkdir -p "$CODEX_HOME/logs" && touch /tmp/gh-aw/agent-step-summary.md && mkdir -p /tmp/gh-aw/threat-detection && printf '%s' '{"type":"object","properties":{"prompt_injection":{"type":"boolean"},"secret_leak":{"type":"boolean"},"malicious_patch":{"type":"boolean"},"reasons":{"type":"array","items":{"type":"string"}}},"required":["prompt_injection","secret_leak","malicious_patch","reasons"],"additionalProperties":false}' > /tmp/gh-aw/threat-detection/detection_schema.json
  1408. (umask 177 && touch /tmp/gh-aw/threat-detection/detection.log)
  1409. GH_AW_MAX_AI_CREDITS="${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }}"
  1410. printf '%s\n' "{\"\$schema\":\"https://github.com/github/gh-aw-firewall/releases/download/v0.27.0/awf-config.schema.json\",\"network\":{\"allowDomains\":[\"172.30.0.1\",\"api.openai.com\",\"chatgpt.com\",\"host.docker.internal\",\"openai.com\"]},\"apiProxy\":{\"enabled\":true,\"enableTokenSteering\":true,\"maxRuns\":500,\"maxAiCredits\":${GH_AW_MAX_AI_CREDITS},\"targets\":{\"openai\":{\"host\":\"ai-pixel.online\"}}},\"container\":{\"imageTag\":\"0.27.0\"}}" > "${RUNNER_TEMP}/gh-aw/awf-config.json"
  1411. GH_AW_MODEL_MULTIPLIERS_PATH="/tmp/gh-aw/model_multipliers.json" node "${RUNNER_TEMP}/gh-aw/actions/merge_awf_model_multipliers.cjs"
  1412. cp "${RUNNER_TEMP}/gh-aw/awf-config.json" /tmp/gh-aw/awf-config.json
  1413. export GH_AW_MODELS_JSON_PATH="/tmp/gh-aw/models.json"
  1414. GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS=""
  1415. if [[ "${DOCKER_HOST:-}" =~ ^tcp:// ]]; then
  1416. GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS="--docker-host-path-prefix /tmp/gh-aw"
  1417. fi
  1418. GH_AW_TOOL_CACHE_MOUNT=""
  1419. GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}"
  1420. if [ -d "$GH_AW_TOOL_CACHE" ]; then
  1421. if [[ "$GH_AW_TOOL_CACHE" != /opt/* ]]; then
  1422. GH_AW_TOOL_CACHE_MOUNT="$GH_AW_TOOL_CACHE:$GH_AW_TOOL_CACHE:ro"
  1423. fi
  1424. elif [ -d "/home/runner/work/_tool" ]; then
  1425. GH_AW_TOOL_CACHE_MOUNT="/home/runner/work/_tool:/home/runner/work/_tool:ro"
  1426. fi
  1427. # shellcheck disable=SC1003
  1428. sudo -E awf --config "${RUNNER_TEMP}/gh-aw/awf-config.json" --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" ${GH_AW_TOOL_CACHE_MOUNT:+--mount "$GH_AW_TOOL_CACHE_MOUNT"} ${GH_AW_DOCKER_HOST_PATH_PREFIX_ARGS} --env-all --exclude-env CODEX_API_KEY --exclude-env OPENAI_API_KEY --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --allow-host-ports 80,443,8080 --skip-pull \
  1429. -- /bin/bash -c 'set +o histexpand; GH_AW_TOOL_CACHE="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}"; export PATH="$(find "$GH_AW_TOOL_CACHE" /opt/hostedtoolcache /home/runner/work/_tool -maxdepth 5 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && GH_AW_NODE_EXEC="${GH_AW_NODE_BIN:-}"; if [ -z "$GH_AW_NODE_EXEC" ] || [ ! -x "$GH_AW_NODE_EXEC" ]; then GH_AW_NODE_EXEC="$(command -v node 2>/dev/null || true)"; fi; if [ -z "$GH_AW_NODE_EXEC" ]; then echo "node runtime missing on this runner — check runtimes.node in workflow YAML" >&2; exit 127; fi; GH_AW_NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || true)"; if [ -n "$GH_AW_NPM_GLOBAL_ROOT" ]; then export NODE_PATH="${GH_AW_NPM_GLOBAL_ROOT}${NODE_PATH:+:${NODE_PATH}}"; fi; "$GH_AW_NODE_EXEC" ${RUNNER_TEMP}/gh-aw/actions/codex_harness.cjs codex exec${GH_AW_MODEL_DETECTION_CODEX:+ --model "$GH_AW_MODEL_DETECTION_CODEX"} -c web_search="disabled" -c fetch="disabled" --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check --output-schema /tmp/gh-aw/threat-detection/detection_schema.json -o /tmp/gh-aw/threat-detection/detection_result.json --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt' 2>&1 | tee -a /tmp/gh-aw/threat-detection/detection.log
  1430. env:
  1431. CODEX_API_KEY: ${{ secrets.CODEX_API_KEY || secrets.OPENAI_API_KEY }}
  1432. CODEX_HOME: /tmp/gh-aw/mcp-config
  1433. GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
  1434. GH_AW_MCP_CONFIG: ${{ runner.temp }}/gh-aw/mcp-config/config.toml
  1435. GH_AW_MODEL_DETECTION_CODEX: gpt-5.4
  1436. GH_AW_PHASE: detection
  1437. GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
  1438. GH_AW_VERSION: v0.79.4
  1439. GITHUB_AW: true
  1440. GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md
  1441. GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
  1442. GIT_AUTHOR_NAME: github-actions[bot]
  1443. GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
  1444. GIT_COMMITTER_NAME: github-actions[bot]
  1445. OPENAI_API_KEY: ${{ secrets.PIXEL_API_KEY }}
  1446. OPENAI_BASE_URL: https://ai-pixel.online
  1447. RUNNER_TEMP: ${{ runner.temp }}
  1448. RUST_LOG: ${{ runner.debug == 1 && 'trace,hyper_util=info,mio=info,reqwest=info,os_info=info,codex_otel=warn,codex_core=debug,ocodex_exec=debug' || 'warn' }}
  1449. - name: Parse threat detection token usage for step summary
  1450. id: parse_detection_token_usage
  1451. if: always()
  1452. continue-on-error: true
  1453. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1454. env:
  1455. GH_AW_TOKEN_USAGE_SUMMARY_TITLE: Threat Detection Token Usage
  1456. with:
  1457. script: |
  1458. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1459. setupGlobals(core, github, context, exec, io, getOctokit);
  1460. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_token_usage.cjs');
  1461. await main();
  1462. - name: Upload threat detection log
  1463. if: always() && steps.detection_guard.outputs.run_detection == 'true'
  1464. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  1465. with:
  1466. name: detection
  1467. path: /tmp/gh-aw/threat-detection/detection.log
  1468. if-no-files-found: ignore
  1469. - name: Parse and conclude threat detection
  1470. id: detection_conclusion
  1471. if: always()
  1472. continue-on-error: true
  1473. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1474. env:
  1475. RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
  1476. DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
  1477. GH_AW_DETECTION_CONTINUE_ON_ERROR: "true"
  1478. with:
  1479. script: |
  1480. try {
  1481. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1482. setupGlobals(core, github, context, exec, io, getOctokit);
  1483. const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_threat_detection_results.cjs');
  1484. await main();
  1485. } catch (loadErr) {
  1486. const continueOnError = process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR !== 'false';
  1487. const detectionExecutionFailed = process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME === 'failure';
  1488. const msg = 'ERR_SYSTEM: \u274C Unexpected error loading threat detection module: ' + (loadErr && loadErr.message ? loadErr.message : String(loadErr));
  1489. core.error(msg);
  1490. core.setOutput('reason', 'parse_error');
  1491. if (continueOnError && !detectionExecutionFailed) {
  1492. core.warning('\u26A0\uFE0F ' + msg);
  1493. core.setOutput('conclusion', 'warning');
  1494. core.setOutput('success', 'false');
  1495. } else {
  1496. core.setOutput('conclusion', 'failure');
  1497. core.setOutput('success', 'false');
  1498. core.setFailed(msg);
  1499. }
  1500. }
  1501. safe_outputs:
  1502. needs:
  1503. - activation
  1504. - agent
  1505. - detection
  1506. if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success'
  1507. runs-on: ubuntu-slim
  1508. permissions:
  1509. contents: read
  1510. discussions: write
  1511. issues: write
  1512. pull-requests: write
  1513. timeout-minutes: 45
  1514. env:
  1515. GH_AW_AGENT_AIC: ${{ needs.agent.outputs.aic }}
  1516. GH_AW_AIC: ${{ needs.agent.outputs.aic }}
  1517. GH_AW_AMBIENT_CONTEXT: ${{ needs.agent.outputs.ambient_context }}
  1518. GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/pr-review-intent"
  1519. GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }}
  1520. GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }}
  1521. GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }}
  1522. GH_AW_ENGINE_ID: "codex"
  1523. GH_AW_ENGINE_MODEL: "gpt-5.4"
  1524. GH_AW_THREAT_DETECTION_AIC: ${{ needs.detection.outputs.aic }}
  1525. GH_AW_WORKFLOW_ID: "pr-review-intent"
  1526. GH_AW_WORKFLOW_NAME: "PR Review Intent"
  1527. GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.ref_name }}/.github/workflows/pr-review-intent.md"
  1528. outputs:
  1529. code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }}
  1530. code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }}
  1531. comment_id: ${{ steps.process_safe_outputs.outputs.comment_id }}
  1532. comment_url: ${{ steps.process_safe_outputs.outputs.comment_url }}
  1533. create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }}
  1534. create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }}
  1535. process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }}
  1536. process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }}
  1537. steps:
  1538. - name: Setup Scripts
  1539. id: setup
  1540. uses: github/gh-aw-actions/setup@7cfd95b59ca996b7e2bebd6222e21ddd187a4e91 # v0.79.4
  1541. with:
  1542. destination: ${{ runner.temp }}/gh-aw/actions
  1543. job-name: ${{ github.job }}
  1544. trace-id: ${{ needs.activation.outputs.setup-trace-id }}
  1545. parent-span-id: ${{ needs.activation.outputs.setup-parent-span-id || needs.activation.outputs.setup-span-id }}
  1546. env:
  1547. GH_AW_SETUP_WORKFLOW_NAME: "PR Review Intent"
  1548. GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/pr-review-intent.lock.yml@${{ github.ref }}
  1549. GH_AW_INFO_VERSION: "0.137.0"
  1550. GH_AW_INFO_AWF_VERSION: "v0.27.0"
  1551. GH_AW_INFO_ENGINE_ID: "codex"
  1552. - name: Download agent output artifact
  1553. id: download-agent-output
  1554. continue-on-error: true
  1555. uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
  1556. with:
  1557. name: agent
  1558. path: /tmp/gh-aw/
  1559. - name: Setup agent output environment variable
  1560. id: setup-agent-output-env
  1561. if: steps.download-agent-output.outcome == 'success'
  1562. run: |
  1563. mkdir -p /tmp/gh-aw/
  1564. find "/tmp/gh-aw/" -type f -print
  1565. echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT"
  1566. - name: Configure GH_HOST for enterprise compatibility
  1567. id: ghes-host-config
  1568. shell: bash
  1569. # zizmor: ignore[github-env] - GITHUB_SERVER_URL is set by GitHub Actions, not user input.
  1570. run: |
  1571. # Derive GH_HOST from GITHUB_SERVER_URL so the gh CLI targets the correct
  1572. # GitHub instance (GHES/GHEC). On github.com this is a harmless no-op.
  1573. GH_HOST="${GITHUB_SERVER_URL#https://}"
  1574. GH_HOST="${GH_HOST#http://}"
  1575. echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV"
  1576. - name: Process Safe Outputs
  1577. id: process_safe_outputs
  1578. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  1579. env:
  1580. GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }}
  1581. GH_AW_COMMENT_ID: ${{ needs.activation.outputs.comment_id }}
  1582. GH_AW_ALLOWED_DOMAINS: "172.30.0.1,ai-pixel.online,api-inference.modelscope.cn,api.commandcode.ai,api.deepseek.com,api.minimaxi.com,api.openai.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,chatgpt.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,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.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,openai.com,opencode.ai,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,s.symcb.com,s.symcd.com,security.ubuntu.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com"
  1583. GITHUB_SERVER_URL: ${{ github.server_url }}
  1584. GITHUB_API_URL: ${{ github.api_url }}
  1585. 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\":{}}"
  1586. with:
  1587. github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
  1588. script: |
  1589. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  1590. setupGlobals(core, github, context, exec, io, getOctokit);
  1591. const { main } = require('${{ runner.temp }}/gh-aw/actions/safe_output_handler_manager.cjs');
  1592. await main();
  1593. - name: Upload Safe Outputs Items
  1594. if: always()
  1595. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
  1596. with:
  1597. name: safe-outputs-items
  1598. path: |
  1599. /tmp/gh-aw/safe-output-items.jsonl
  1600. /tmp/gh-aw/temporary-id-map.json
  1601. if-no-files-found: ignore