agentics-maintenance.yml 27 KB

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