agentics-maintenance.yml 29 KB

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