agentics-maintenance.yml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. # This file was automatically generated by pkg/workflow/maintenance_workflow.go (v1.0.1). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
  2. #
  3. # ___ _ _
  4. # / _ \ | | (_)
  5. # | |_| | __ _ ___ _ __ | |_ _ ___
  6. # | _ |/ _` |/ _ \ '_ \| __| |/ __|
  7. # | | | | (_| | __/ | | | |_| | (__
  8. # \_| |_/\__, |\___|_| |_|\__|_|\___|
  9. # __/ |
  10. # _ _ |___/
  11. # | | | | / _| |
  12. # | | | | ___ _ __ _ __| |_| | _____ ____
  13. # | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___|
  14. # \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \
  15. # \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/
  16. #
  17. #
  18. # To regenerate this workflow, run:
  19. # gh aw compile
  20. # Not all edits will cause changes to this file.
  21. #
  22. # For more information: https://github.github.com/gh-aw/introduction/overview/
  23. #
  24. # This file defines the generated agentic maintenance workflow for this repository.
  25. # It runs scheduled cleanup for expiring safe outputs and supports manual maintenance operations.
  26. #
  27. # This workflow is generated automatically when workflows use expiring safe outputs,
  28. # when workflows enable steering (safe-outputs.steer), declare compaction-enabled
  29. # ledgers (tools.ledger) or work queues, or when repository maintenance features are
  30. # enabled in .github/workflows/aw.json.
  31. #
  32. # To disable maintenance workflow generation, set in .github/workflows/aw.json:
  33. # {"maintenance": false}
  34. #
  35. # Agentic maintenance docs:
  36. # https://github.github.com/gh-aw/reference/ephemerals/#manual-maintenance-operations
  37. #
  38. name: Agentic Maintenance
  39. on:
  40. schedule:
  41. - cron: "37 0 * * *" # Daily (based on minimum expires: 30 days)
  42. workflow_dispatch:
  43. inputs:
  44. operation:
  45. description: 'Optional maintenance operation to run'
  46. required: false
  47. type: choice
  48. default: 'none'
  49. options:
  50. - 'none'
  51. - 'disable'
  52. - 'enable'
  53. - 'update'
  54. - 'upgrade'
  55. - 'safe_outputs'
  56. - 'create_labels'
  57. - 'activity_report'
  58. - 'close_agentic_workflows_issues'
  59. - 'update_pull_request_branches'
  60. - 'validate'
  61. - 'forecast'
  62. run_url:
  63. description: 'Run URL or run ID to replay safe outputs from (e.g. https://github.com/owner/repo/actions/runs/12345 or 12345). Required when operation is safe_outputs.'
  64. required: false
  65. type: string
  66. default: ''
  67. workflow_call:
  68. inputs:
  69. operation:
  70. description: 'Optional maintenance operation to run (disable, enable, update, upgrade, safe_outputs, create_labels, activity_report, close_agentic_workflows_issues, update_pull_request_branches, validate, forecast)'
  71. required: false
  72. type: string
  73. default: ''
  74. run_url:
  75. description: 'Run URL or run ID to replay safe outputs from (e.g. https://github.com/owner/repo/actions/runs/12345 or 12345). Required when operation is safe_outputs.'
  76. required: false
  77. type: string
  78. default: ''
  79. outputs:
  80. operation_completed:
  81. description: 'The maintenance operation that was completed (empty when none ran or a scheduled job ran)'
  82. value: ${{ jobs.run_operation.outputs.operation || (inputs.operation == 'safe_outputs' || inputs.operation == 'create_labels' || inputs.operation == 'activity_report' || inputs.operation == 'close_agentic_workflows_issues' || inputs.operation == 'update_pull_request_branches' || inputs.operation == 'validate' || inputs.operation == 'forecast') && inputs.operation || '' }}
  83. applied_run_url:
  84. description: 'The run URL that safe outputs were applied from'
  85. value: ${{ jobs.apply_safe_outputs.outputs.run_url }}
  86. # Jobs request only the permissions needed for their individual maintenance operations.
  87. permissions: {}
  88. # Serialize maintenance runs to avoid overlapping writes to repository resources.
  89. concurrency:
  90. group: ${{ github.workflow }}-${{ github.repository }}
  91. cancel-in-progress: false
  92. jobs:
  93. close-expired-discussions:
  94. name: Close expired discussions
  95. if: ${{ (!(github.event.repository.fork)) && github.event_name != 'push' && (github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' || inputs.operation == '' || inputs.operation == 'none') }}
  96. runs-on: ubuntu-slim
  97. # Closing expired resources requires write access to this resource type only.
  98. permissions:
  99. discussions: write
  100. steps:
  101. - name: Setup Scripts
  102. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  103. with:
  104. destination: ${{ runner.temp }}/gh-aw/actions
  105. - name: Close expired discussions
  106. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  107. with:
  108. script: |
  109. const path = require('path');
  110. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  111. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  112. setupGlobals(core, github, context, exec, io, getOctokit);
  113. const { main } = require(path.join(actionsDir, 'close_expired_discussions.cjs'));
  114. await main();
  115. close-expired-issues:
  116. name: Close expired issues
  117. if: ${{ (!(github.event.repository.fork)) && github.event_name != 'push' && (github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' || inputs.operation == '' || inputs.operation == 'none') }}
  118. runs-on: ubuntu-slim
  119. # Closing expired resources requires write access to this resource type only.
  120. permissions:
  121. issues: write
  122. steps:
  123. - name: Setup Scripts
  124. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  125. with:
  126. destination: ${{ runner.temp }}/gh-aw/actions
  127. - name: Close expired issues
  128. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  129. with:
  130. script: |
  131. const path = require('path');
  132. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  133. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  134. setupGlobals(core, github, context, exec, io, getOctokit);
  135. const { main } = require(path.join(actionsDir, 'close_expired_issues.cjs'));
  136. await main();
  137. close-expired-pull-requests:
  138. name: Close expired pull requests
  139. if: ${{ (!(github.event.repository.fork)) && github.event_name != 'push' && (github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' || inputs.operation == '' || inputs.operation == 'none') }}
  140. runs-on: ubuntu-slim
  141. # Closing expired resources requires write access to this resource type only.
  142. permissions:
  143. pull-requests: write
  144. steps:
  145. - name: Setup Scripts
  146. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  147. with:
  148. destination: ${{ runner.temp }}/gh-aw/actions
  149. - name: Close expired pull requests
  150. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  151. with:
  152. script: |
  153. const path = require('path');
  154. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  155. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  156. setupGlobals(core, github, context, exec, io, getOctokit);
  157. const { main } = require(path.join(actionsDir, 'close_expired_pull_requests.cjs'));
  158. await main();
  159. run_operation:
  160. name: Run maintenance operation
  161. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation != '' && inputs.operation != 'none' && inputs.operation != 'safe_outputs' && inputs.operation != 'create_labels' && inputs.operation != 'activity_report' && inputs.operation != 'close_agentic_workflows_issues' && inputs.operation != 'clean_cache_memories' && inputs.operation != 'update_pull_request_branches' && inputs.operation != 'validate' && inputs.operation != 'forecast' && (!(github.event.repository.fork)) }}
  162. runs-on: ubuntu-slim
  163. # Updates, upgrades, and workflow enable/disable operations need repository write access.
  164. permissions:
  165. actions: write
  166. contents: write
  167. pull-requests: write
  168. outputs:
  169. operation: ${{ steps.record.outputs.operation }}
  170. steps:
  171. - name: Checkout repository
  172. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  173. with:
  174. persist-credentials: false
  175. - name: Setup Scripts
  176. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  177. with:
  178. destination: ${{ runner.temp }}/gh-aw/actions
  179. - name: Check admin/maintainer permissions
  180. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  181. with:
  182. github-token: ${{ secrets.GITHUB_TOKEN }}
  183. script: |
  184. const path = require('path');
  185. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  186. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  187. setupGlobals(core, github, context, exec, io, getOctokit);
  188. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  189. await main();
  190. - name: Install gh-aw
  191. uses: github/gh-aw-actions/setup-cli@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  192. with:
  193. version: v1.0.1
  194. - name: Run operation
  195. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  196. env:
  197. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  198. GH_AW_OPERATION: ${{ inputs.operation }}
  199. GH_AW_CMD_PREFIX: gh aw
  200. with:
  201. github-token: ${{ secrets.GITHUB_TOKEN }}
  202. script: |
  203. const path = require('path');
  204. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  205. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  206. setupGlobals(core, github, context, exec, io, getOctokit);
  207. const { main } = require(path.join(actionsDir, 'run_operation_update_upgrade.cjs'));
  208. await main();
  209. - name: Record outputs
  210. id: record
  211. env:
  212. GH_AW_OPERATION: ${{ inputs.operation }}
  213. run: echo "operation=$GH_AW_OPERATION" >> "$GITHUB_OUTPUT"
  214. update_pull_request_branches:
  215. name: Update pull request branches
  216. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'update_pull_request_branches' && (!(github.event.repository.fork)) }}
  217. runs-on: ubuntu-slim
  218. # Branch updates may write commits and update pull requests.
  219. permissions:
  220. contents: write
  221. pull-requests: write
  222. steps:
  223. - name: Setup Scripts
  224. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  225. with:
  226. destination: ${{ runner.temp }}/gh-aw/actions
  227. - name: Check admin/maintainer permissions
  228. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  229. with:
  230. github-token: ${{ secrets.GITHUB_TOKEN }}
  231. script: |
  232. const path = require('path');
  233. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  234. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  235. setupGlobals(core, github, context, exec, io, getOctokit);
  236. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  237. await main();
  238. - name: Update pull request branches
  239. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  240. env:
  241. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  242. with:
  243. github-token: ${{ secrets.GITHUB_TOKEN }}
  244. script: |
  245. const path = require('path');
  246. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  247. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  248. setupGlobals(core, github, context, exec, io, getOctokit);
  249. const { main } = require(path.join(actionsDir, 'update_pull_request_branches.cjs'));
  250. await main();
  251. apply_safe_outputs:
  252. name: Apply safe outputs
  253. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'safe_outputs' && (!(github.event.repository.fork)) }}
  254. runs-on: ubuntu-slim
  255. # Replay can create or update any supported safe-output resource.
  256. permissions:
  257. actions: read
  258. contents: write
  259. discussions: write
  260. issues: write
  261. pull-requests: write
  262. outputs:
  263. run_url: ${{ steps.record.outputs.run_url }}
  264. steps:
  265. - name: Checkout actions folder
  266. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  267. with:
  268. sparse-checkout: |
  269. actions
  270. clean: false
  271. persist-credentials: false
  272. - name: Setup Scripts
  273. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  274. with:
  275. destination: ${{ runner.temp }}/gh-aw/actions
  276. - name: Check admin/maintainer permissions
  277. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  278. with:
  279. github-token: ${{ secrets.GITHUB_TOKEN }}
  280. script: |
  281. const path = require('path');
  282. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  283. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  284. setupGlobals(core, github, context, exec, io, getOctokit);
  285. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  286. await main();
  287. - name: Apply Safe Outputs
  288. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  289. env:
  290. GH_AW_JOB_CHECK_RUN_ID: ${{ job.check_run_id }}
  291. GH_AW_WORKFLOW_ID: "agentics-maintenance"
  292. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  293. GH_AW_RUN_URL: ${{ inputs.run_url }}
  294. with:
  295. github-token: ${{ secrets.GITHUB_TOKEN }}
  296. script: |
  297. const path = require('path');
  298. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  299. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  300. setupGlobals(core, github, context, exec, io, getOctokit);
  301. const { main } = require(path.join(actionsDir, 'apply_safe_outputs_replay.cjs'));
  302. await main();
  303. - name: Record outputs
  304. id: record
  305. env:
  306. GH_AW_RUN_URL: ${{ inputs.run_url }}
  307. run: echo "run_url=$GH_AW_RUN_URL" >> "$GITHUB_OUTPUT"
  308. create_labels:
  309. name: Create labels
  310. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'create_labels' && (!(github.event.repository.fork)) }}
  311. runs-on: ubuntu-slim
  312. # Creating repository labels uses the issues API.
  313. permissions:
  314. contents: read
  315. issues: write
  316. steps:
  317. - name: Checkout repository
  318. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  319. with:
  320. persist-credentials: false
  321. - name: Setup Scripts
  322. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  323. with:
  324. destination: ${{ runner.temp }}/gh-aw/actions
  325. - name: Check admin/maintainer permissions
  326. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  327. with:
  328. github-token: ${{ secrets.GITHUB_TOKEN }}
  329. script: |
  330. const path = require('path');
  331. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  332. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  333. setupGlobals(core, github, context, exec, io, getOctokit);
  334. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  335. await main();
  336. - name: Install gh-aw
  337. uses: github/gh-aw-actions/setup-cli@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  338. with:
  339. version: v1.0.1
  340. - name: Create missing labels
  341. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  342. env:
  343. GH_AW_CMD_PREFIX: gh aw
  344. with:
  345. github-token: ${{ secrets.GITHUB_TOKEN }}
  346. script: |
  347. const path = require('path');
  348. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  349. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  350. setupGlobals(core, github, context, exec, io, getOctokit);
  351. const { main } = require(path.join(actionsDir, 'create_labels.cjs'));
  352. await main();
  353. activity_report:
  354. name: activity report
  355. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'activity_report' && (!(github.event.repository.fork)) }}
  356. runs-on: ubuntu-slim
  357. timeout-minutes: 120
  358. # Read workflow logs and create the resulting report issue.
  359. permissions:
  360. actions: read
  361. contents: read
  362. issues: write
  363. steps:
  364. - name: Checkout repository
  365. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  366. with:
  367. persist-credentials: false
  368. - name: Setup Scripts
  369. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  370. with:
  371. destination: ${{ runner.temp }}/gh-aw/actions
  372. - name: Check admin/maintainer permissions
  373. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  374. with:
  375. github-token: ${{ secrets.GITHUB_TOKEN }}
  376. script: |
  377. const path = require('path');
  378. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  379. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  380. setupGlobals(core, github, context, exec, io, getOctokit);
  381. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  382. await main();
  383. - name: Install gh-aw
  384. uses: github/gh-aw-actions/setup-cli@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  385. with:
  386. version: v1.0.1
  387. - name: Restore activity report logs cache
  388. id: activity_report_logs_cache
  389. uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  390. with:
  391. path: ./.cache/gh-aw/activity-report-logs
  392. key: ${{ runner.os }}-activity-report-logs-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}
  393. restore-keys: |
  394. ${{ runner.os }}-activity-report-logs-${{ github.repository }}-
  395. ${{ runner.os }}-activity-report-logs-
  396. - name: Download activity report logs
  397. timeout-minutes: 20
  398. shell: bash
  399. env:
  400. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  401. GH_AW_CMD_PREFIX: gh aw
  402. run: |
  403. ${GH_AW_CMD_PREFIX} logs \
  404. --repo "$GITHUB_REPOSITORY" \
  405. --start-date -1w \
  406. --count 500 \
  407. --output ./.cache/gh-aw/activity-report-logs \
  408. --format markdown \
  409. --report-file ./.cache/gh-aw/activity-report-logs/report.md
  410. - name: Save activity report logs cache
  411. if: ${{ always() }}
  412. uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  413. with:
  414. path: ./.cache/gh-aw/activity-report-logs
  415. key: ${{ steps.activity_report_logs_cache.outputs.cache-primary-key }}
  416. - name: Generate activity report issue
  417. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  418. with:
  419. github-token: ${{ secrets.GITHUB_TOKEN }}
  420. script: |
  421. const fs = require('node:fs');
  422. const reportPath = './.cache/gh-aw/activity-report-logs/report.md';
  423. if (!fs.existsSync(reportPath)) {
  424. core.warning('Activity report markdown not found at ' + reportPath + '; skipping issue creation.');
  425. return;
  426. }
  427. let reportBody = '';
  428. try {
  429. reportBody = fs.readFileSync(reportPath, 'utf8').trim();
  430. } catch (error) {
  431. core.warning('Failed to read activity report markdown at ' + reportPath + ': ' + error.message);
  432. return;
  433. }
  434. if (!reportBody) {
  435. core.warning('Activity report markdown is empty at ' + reportPath + '; skipping issue creation.');
  436. return;
  437. }
  438. const repoSlug = context.repo.owner + '/' + context.repo.repo;
  439. const body = [
  440. '### Agentic workflow activity report',
  441. '',
  442. 'Repository: ' + repoSlug,
  443. 'Generated at: ' + new Date().toISOString(),
  444. '',
  445. reportBody,
  446. ].join('\n');
  447. const createdIssue = await github.rest.issues.create({
  448. owner: context.repo.owner,
  449. repo: context.repo.repo,
  450. title: '[aw] agentic status report',
  451. body,
  452. labels: ['agentic-workflows'],
  453. });
  454. core.info('Created issue #' + createdIssue.data.number + ': ' + createdIssue.data.html_url);
  455. forecast_report:
  456. name: forecast report
  457. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'forecast' && (!(github.event.repository.fork)) }}
  458. runs-on: ubuntu-slim
  459. timeout-minutes: 60
  460. # Read workflow logs and create the resulting report issue.
  461. permissions:
  462. actions: read
  463. contents: read
  464. issues: write
  465. steps:
  466. - name: Checkout repository
  467. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  468. with:
  469. persist-credentials: false
  470. - name: Setup Scripts
  471. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  472. with:
  473. destination: ${{ runner.temp }}/gh-aw/actions
  474. - name: Check admin/maintainer permissions
  475. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  476. with:
  477. github-token: ${{ secrets.GITHUB_TOKEN }}
  478. script: |
  479. const path = require('path');
  480. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  481. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  482. setupGlobals(core, github, context, exec, io, getOctokit);
  483. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  484. await main();
  485. - name: Install gh-aw
  486. uses: github/gh-aw-actions/setup-cli@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  487. with:
  488. version: v1.0.1
  489. - name: Restore forecast report logs cache
  490. id: forecast_report_logs_cache
  491. uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  492. with:
  493. path: ./.github/aw/logs
  494. key: ${{ runner.os }}-forecast-report-logs-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}
  495. restore-keys: |
  496. ${{ runner.os }}-forecast-report-logs-${{ github.repository }}-
  497. ${{ runner.os }}-forecast-report-logs-
  498. - name: Generate forecast report
  499. id: generate_forecast_report
  500. timeout-minutes: 30
  501. shell: bash
  502. env:
  503. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  504. GH_AW_CMD_PREFIX: gh aw
  505. run: |
  506. mkdir -p ./.cache/gh-aw/forecast
  507. set +e
  508. ${GH_AW_CMD_PREFIX} forecast --repo "$GITHUB_REPOSITORY" --timeout 30 --verbose --json > ./.cache/gh-aw/forecast/report.json
  509. forecast_exit_code=$?
  510. set -e
  511. if [ "${forecast_exit_code}" -eq 124 ]; then
  512. echo '{"outcome":"timeout","message":"Forecast computation timed out after 30 minutes."}' > ./.cache/gh-aw/forecast/error.json
  513. echo "::error::Forecast computation timed out after 30 minutes."
  514. exit 1
  515. fi
  516. if [ "${forecast_exit_code}" -ne 0 ]; then
  517. echo '{"outcome":"error","message":"Forecast computation failed before producing a report."}' > ./.cache/gh-aw/forecast/error.json
  518. echo "::error::Forecast computation failed with exit code ${forecast_exit_code}."
  519. exit 1
  520. fi
  521. - name: Debug forecast logs folder
  522. if: ${{ always() }}
  523. shell: bash
  524. run: |
  525. if [ ! -d ./.github/aw/logs ]; then
  526. echo "Logs directory not found: ./.github/aw/logs"
  527. exit 0
  528. fi
  529. echo "Files under ./.github/aw/logs:"
  530. find ./.github/aw/logs -type f | sort
  531. - name: Save forecast report logs cache
  532. if: ${{ always() }}
  533. uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  534. with:
  535. path: ./.github/aw/logs
  536. key: ${{ runner.os }}-forecast-report-logs-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}
  537. - name: Generate forecast issue
  538. if: ${{ always() }}
  539. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  540. env:
  541. FORECAST_STEP_OUTCOME: ${{ steps.generate_forecast_report.outcome }}
  542. with:
  543. github-token: ${{ secrets.GITHUB_TOKEN }}
  544. script: |
  545. const path = require('path');
  546. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  547. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  548. setupGlobals(core, github, context, exec, io, getOctokit);
  549. const { main } = require(path.join(actionsDir, 'create_forecast_issue.cjs'));
  550. await main();
  551. close_agentic_workflows_issues:
  552. name: Close agentic workflows issues
  553. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'close_agentic_workflows_issues' && (!(github.event.repository.fork)) }}
  554. runs-on: ubuntu-slim
  555. # Closing no-repro issues requires issues: write.
  556. permissions:
  557. issues: write
  558. steps:
  559. - name: Setup Scripts
  560. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  561. with:
  562. destination: ${{ runner.temp }}/gh-aw/actions
  563. - name: Check admin/maintainer permissions
  564. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  565. with:
  566. github-token: ${{ secrets.GITHUB_TOKEN }}
  567. script: |
  568. const path = require('path');
  569. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  570. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  571. setupGlobals(core, github, context, exec, io, getOctokit);
  572. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  573. await main();
  574. - name: Close no-repro agentic-workflows issues
  575. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  576. with:
  577. github-token: ${{ secrets.GITHUB_TOKEN }}
  578. script: |
  579. const path = require('path');
  580. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  581. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  582. setupGlobals(core, github, context, exec, io, getOctokit);
  583. const { main } = require(path.join(actionsDir, 'close_agentic_workflows_issues.cjs'));
  584. await main();
  585. validate_workflows:
  586. name: Validate workflows
  587. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'validate' && (!(github.event.repository.fork)) }}
  588. runs-on: ubuntu-latest
  589. # Read workflow sources and file issues for validation findings.
  590. permissions:
  591. contents: read
  592. issues: write
  593. steps:
  594. - name: Checkout repository
  595. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  596. with:
  597. persist-credentials: false
  598. - name: Setup Scripts
  599. uses: github/gh-aw-actions/setup@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  600. with:
  601. destination: ${{ runner.temp }}/gh-aw/actions
  602. - name: Check admin/maintainer permissions
  603. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  604. with:
  605. github-token: ${{ secrets.GITHUB_TOKEN }}
  606. script: |
  607. const path = require('path');
  608. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  609. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  610. setupGlobals(core, github, context, exec, io, getOctokit);
  611. const { main } = require(path.join(actionsDir, 'check_team_member.cjs'));
  612. await main();
  613. - name: Install gh-aw
  614. uses: github/gh-aw-actions/setup-cli@221ba4f4319de6b8e809d1a15528b3ae6a818aa5 # v1.0.1
  615. with:
  616. version: v1.0.1
  617. - name: Validate workflows and file issue on findings
  618. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  619. env:
  620. GH_AW_CMD_PREFIX: gh aw
  621. with:
  622. github-token: ${{ secrets.GITHUB_TOKEN }}
  623. script: |
  624. const path = require('path');
  625. const actionsDir = path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions');
  626. const { setupGlobals } = require(path.join(actionsDir, 'setup_globals.cjs'));
  627. setupGlobals(core, github, context, exec, io, getOctokit);
  628. const { main } = require(path.join(actionsDir, 'run_validate_workflows.cjs'));
  629. await main();