agentics-maintenance.yml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. # ___ _ _
  2. # / _ \ | | (_)
  3. # | |_| | __ _ ___ _ __ | |_ _ ___
  4. # | _ |/ _` |/ _ \ '_ \| __| |/ __|
  5. # | | | | (_| | __/ | | | |_| | (__
  6. # \_| |_/\__, |\___|_| |_|\__|_|\___|
  7. # __/ |
  8. # _ _ |___/
  9. # | | | | / _| |
  10. # | | | | ___ _ __ _ __| |_| | _____ ____
  11. # | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___|
  12. # \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \
  13. # \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/
  14. #
  15. # This file was automatically generated by pkg/workflow/maintenance_workflow.go (v0.77.5). DO NOT EDIT.
  16. #
  17. # To regenerate this workflow, run:
  18. # gh aw compile
  19. # Not all edits will cause changes to this file.
  20. #
  21. # For more information: https://github.github.com/gh-aw/introduction/overview/
  22. #
  23. # Alternative regeneration methods:
  24. # make recompile
  25. #
  26. # Or use the gh-aw CLI directly:
  27. # ./gh-aw compile --validate --verbose
  28. #
  29. # The workflow is generated when any workflow uses the 'expires' field
  30. # in create-discussions, create-issues, or create-pull-request safe-outputs configuration.
  31. # Schedule frequency is automatically determined by the shortest expiration time.
  32. #
  33. name: Agentic Maintenance
  34. on:
  35. schedule:
  36. - cron: "37 0 * * *" # Daily (based on minimum expires: 30 days)
  37. workflow_dispatch:
  38. inputs:
  39. operation:
  40. description: 'Optional maintenance operation to run'
  41. required: false
  42. type: choice
  43. default: ''
  44. options:
  45. - ''
  46. - 'disable'
  47. - 'enable'
  48. - 'update'
  49. - 'upgrade'
  50. - 'safe_outputs'
  51. - 'create_labels'
  52. - 'activity_report'
  53. - 'close_agentic_workflows_issues'
  54. - 'clean_cache_memories'
  55. - 'update_pull_request_branches'
  56. - 'validate'
  57. - 'forecast'
  58. run_url:
  59. 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.'
  60. required: false
  61. type: string
  62. default: ''
  63. workflow_call:
  64. inputs:
  65. operation:
  66. 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)'
  67. required: false
  68. type: string
  69. default: ''
  70. run_url:
  71. 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.'
  72. required: false
  73. type: string
  74. default: ''
  75. outputs:
  76. operation_completed:
  77. description: 'The maintenance operation that was completed (empty when none ran or a scheduled job ran)'
  78. value: ${{ jobs.run_operation.outputs.operation || inputs.operation }}
  79. applied_run_url:
  80. description: 'The run URL that safe outputs were applied from'
  81. value: ${{ jobs.apply_safe_outputs.outputs.run_url }}
  82. permissions: {}
  83. jobs:
  84. close-expired-entities:
  85. if: ${{ (!(github.event.repository.fork)) && github.event_name != 'push' && (github.event_name != 'workflow_dispatch' && github.event_name != 'workflow_call' || inputs.operation == '') }}
  86. runs-on: ubuntu-slim
  87. permissions:
  88. discussions: write
  89. issues: write
  90. pull-requests: write
  91. steps:
  92. - name: Setup Scripts
  93. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  94. with:
  95. destination: ${{ runner.temp }}/gh-aw/actions
  96. - name: Close expired discussions
  97. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  98. with:
  99. script: |
  100. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  101. setupGlobals(core, github, context, exec, io, getOctokit);
  102. const { main } = require('${{ runner.temp }}/gh-aw/actions/close_expired_discussions.cjs');
  103. await main();
  104. - name: Close expired issues
  105. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  106. with:
  107. script: |
  108. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  109. setupGlobals(core, github, context, exec, io, getOctokit);
  110. const { main } = require('${{ runner.temp }}/gh-aw/actions/close_expired_issues.cjs');
  111. await main();
  112. - name: Close expired pull requests
  113. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  114. with:
  115. script: |
  116. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  117. setupGlobals(core, github, context, exec, io, getOctokit);
  118. const { main } = require('${{ runner.temp }}/gh-aw/actions/close_expired_pull_requests.cjs');
  119. await main();
  120. cleanup-cache-memory:
  121. 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') }}
  122. runs-on: ubuntu-slim
  123. permissions:
  124. actions: write
  125. steps:
  126. - name: Setup Scripts
  127. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  128. with:
  129. destination: ${{ runner.temp }}/gh-aw/actions
  130. - name: Cleanup outdated cache-memory entries
  131. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  132. with:
  133. script: |
  134. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  135. setupGlobals(core, github, context, exec, io, getOctokit);
  136. const { main } = require('${{ runner.temp }}/gh-aw/actions/cleanup_cache_memory.cjs');
  137. await main();
  138. run_operation:
  139. 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)) }}
  140. runs-on: ubuntu-slim
  141. permissions:
  142. actions: write
  143. contents: write
  144. pull-requests: write
  145. outputs:
  146. operation: ${{ steps.record.outputs.operation }}
  147. steps:
  148. - name: Checkout repository
  149. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  150. with:
  151. persist-credentials: false
  152. - name: Setup Scripts
  153. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  154. with:
  155. destination: ${{ runner.temp }}/gh-aw/actions
  156. - name: Check admin/maintainer permissions
  157. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  158. with:
  159. github-token: ${{ secrets.GITHUB_TOKEN }}
  160. script: |
  161. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  162. setupGlobals(core, github, context, exec, io, getOctokit);
  163. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  164. await main();
  165. - name: Install gh-aw
  166. uses: github/gh-aw-actions/setup-cli@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  167. with:
  168. version: v0.77.5
  169. - name: Run operation
  170. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  171. env:
  172. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  173. GH_AW_OPERATION: ${{ inputs.operation }}
  174. GH_AW_CMD_PREFIX: gh aw
  175. with:
  176. github-token: ${{ secrets.GITHUB_TOKEN }}
  177. script: |
  178. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  179. setupGlobals(core, github, context, exec, io, getOctokit);
  180. const { main } = require('${{ runner.temp }}/gh-aw/actions/run_operation_update_upgrade.cjs');
  181. await main();
  182. - name: Record outputs
  183. id: record
  184. run: echo "operation=${{ inputs.operation }}" >> "$GITHUB_OUTPUT"
  185. update_pull_request_branches:
  186. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'update_pull_request_branches' && (!(github.event.repository.fork)) }}
  187. runs-on: ubuntu-slim
  188. permissions:
  189. contents: write
  190. pull-requests: write
  191. steps:
  192. - name: Setup Scripts
  193. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  194. with:
  195. destination: ${{ runner.temp }}/gh-aw/actions
  196. - name: Check admin/maintainer permissions
  197. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  198. with:
  199. github-token: ${{ secrets.GITHUB_TOKEN }}
  200. script: |
  201. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  202. setupGlobals(core, github, context, exec, io, getOctokit);
  203. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  204. await main();
  205. - name: Update pull request branches
  206. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  207. env:
  208. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  209. with:
  210. github-token: ${{ secrets.GITHUB_TOKEN }}
  211. script: |
  212. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  213. setupGlobals(core, github, context, exec, io, getOctokit);
  214. const { main } = require('${{ runner.temp }}/gh-aw/actions/update_pull_request_branches.cjs');
  215. await main();
  216. apply_safe_outputs:
  217. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'safe_outputs' && (!(github.event.repository.fork)) }}
  218. runs-on: ubuntu-slim
  219. permissions:
  220. actions: read
  221. contents: write
  222. discussions: write
  223. issues: write
  224. pull-requests: write
  225. outputs:
  226. run_url: ${{ steps.record.outputs.run_url }}
  227. steps:
  228. - name: Checkout actions folder
  229. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  230. with:
  231. sparse-checkout: |
  232. actions
  233. persist-credentials: false
  234. - name: Setup Scripts
  235. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  236. with:
  237. destination: ${{ runner.temp }}/gh-aw/actions
  238. - name: Check admin/maintainer permissions
  239. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  240. with:
  241. github-token: ${{ secrets.GITHUB_TOKEN }}
  242. script: |
  243. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  244. setupGlobals(core, github, context, exec, io, getOctokit);
  245. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  246. await main();
  247. - name: Apply Safe Outputs
  248. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  249. env:
  250. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  251. GH_AW_RUN_URL: ${{ inputs.run_url }}
  252. with:
  253. github-token: ${{ secrets.GITHUB_TOKEN }}
  254. script: |
  255. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  256. setupGlobals(core, github, context, exec, io, getOctokit);
  257. const { main } = require('${{ runner.temp }}/gh-aw/actions/apply_safe_outputs_replay.cjs');
  258. await main();
  259. - name: Record outputs
  260. id: record
  261. run: echo "run_url=${{ inputs.run_url }}" >> "$GITHUB_OUTPUT"
  262. create_labels:
  263. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'create_labels' && (!(github.event.repository.fork)) }}
  264. runs-on: ubuntu-slim
  265. permissions:
  266. contents: read
  267. issues: write
  268. steps:
  269. - name: Checkout repository
  270. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  271. with:
  272. persist-credentials: false
  273. - name: Setup Scripts
  274. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  275. with:
  276. destination: ${{ runner.temp }}/gh-aw/actions
  277. - name: Check admin/maintainer permissions
  278. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  279. with:
  280. github-token: ${{ secrets.GITHUB_TOKEN }}
  281. script: |
  282. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  283. setupGlobals(core, github, context, exec, io, getOctokit);
  284. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  285. await main();
  286. - name: Install gh-aw
  287. uses: github/gh-aw-actions/setup-cli@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  288. with:
  289. version: v0.77.5
  290. - name: Create missing labels
  291. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  292. env:
  293. GH_AW_CMD_PREFIX: gh aw
  294. with:
  295. github-token: ${{ secrets.GITHUB_TOKEN }}
  296. script: |
  297. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  298. setupGlobals(core, github, context, exec, io, getOctokit);
  299. const { main } = require('${{ runner.temp }}/gh-aw/actions/create_labels.cjs');
  300. await main();
  301. activity_report:
  302. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'activity_report' && (!(github.event.repository.fork)) }}
  303. runs-on: ubuntu-slim
  304. timeout-minutes: 120
  305. permissions:
  306. actions: read
  307. contents: read
  308. issues: write
  309. steps:
  310. - name: Checkout repository
  311. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  312. with:
  313. persist-credentials: false
  314. - name: Setup Scripts
  315. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  316. with:
  317. destination: ${{ runner.temp }}/gh-aw/actions
  318. - name: Check admin/maintainer permissions
  319. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  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/check_team_member.cjs');
  326. await main();
  327. - name: Install gh-aw
  328. uses: github/gh-aw-actions/setup-cli@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  329. with:
  330. version: v0.77.5
  331. - name: Restore activity report logs cache
  332. id: activity_report_logs_cache
  333. uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
  334. with:
  335. path: ./.cache/gh-aw/activity-report-logs
  336. key: ${{ runner.os }}-activity-report-logs-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}
  337. restore-keys: |
  338. ${{ runner.os }}-activity-report-logs-${{ github.repository }}-
  339. ${{ runner.os }}-activity-report-logs-
  340. - name: Download activity report logs
  341. timeout-minutes: 20
  342. shell: bash
  343. env:
  344. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  345. GH_AW_CMD_PREFIX: gh aw
  346. run: |
  347. ${GH_AW_CMD_PREFIX} logs \
  348. --repo "${{ github.repository }}" \
  349. --start-date -1w \
  350. --count 100 \
  351. --output ./.cache/gh-aw/activity-report-logs \
  352. --format markdown \
  353. > ./.cache/gh-aw/activity-report-logs/report.md
  354. - name: Save activity report logs cache
  355. if: ${{ always() }}
  356. uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
  357. with:
  358. path: ./.cache/gh-aw/activity-report-logs
  359. key: ${{ steps.activity_report_logs_cache.outputs.cache-primary-key }}
  360. - name: Generate activity report issue
  361. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  362. with:
  363. github-token: ${{ secrets.GITHUB_TOKEN }}
  364. script: |
  365. const fs = require('node:fs');
  366. const reportPath = './.cache/gh-aw/activity-report-logs/report.md';
  367. if (!fs.existsSync(reportPath)) {
  368. core.warning('Activity report markdown not found at ' + reportPath + '; skipping issue creation.');
  369. return;
  370. }
  371. let reportBody = '';
  372. try {
  373. reportBody = fs.readFileSync(reportPath, 'utf8').trim();
  374. } catch (error) {
  375. core.warning('Failed to read activity report markdown at ' + reportPath + ': ' + error.message);
  376. return;
  377. }
  378. if (!reportBody) {
  379. core.warning('Activity report markdown is empty at ' + reportPath + '; skipping issue creation.');
  380. return;
  381. }
  382. const repoSlug = context.repo.owner + '/' + context.repo.repo;
  383. const body = [
  384. '### Agentic workflow activity report',
  385. '',
  386. 'Repository: ' + repoSlug,
  387. 'Generated at: ' + new Date().toISOString(),
  388. '',
  389. reportBody,
  390. ].join('\n');
  391. const createdIssue = await github.rest.issues.create({
  392. owner: context.repo.owner,
  393. repo: context.repo.repo,
  394. title: '[aw] agentic status report',
  395. body,
  396. labels: ['agentic-workflows'],
  397. });
  398. core.info('Created issue #' + createdIssue.data.number + ': ' + createdIssue.data.html_url);
  399. forecast_report:
  400. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'forecast' && (!(github.event.repository.fork)) }}
  401. runs-on: ubuntu-slim
  402. timeout-minutes: 60
  403. permissions:
  404. actions: read
  405. contents: read
  406. issues: write
  407. steps:
  408. - name: Checkout repository
  409. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  410. with:
  411. persist-credentials: false
  412. - name: Setup Scripts
  413. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  414. with:
  415. destination: ${{ runner.temp }}/gh-aw/actions
  416. - name: Check admin/maintainer permissions
  417. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  418. with:
  419. github-token: ${{ secrets.GITHUB_TOKEN }}
  420. script: |
  421. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  422. setupGlobals(core, github, context, exec, io, getOctokit);
  423. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  424. await main();
  425. - name: Install gh-aw
  426. uses: github/gh-aw-actions/setup-cli@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  427. with:
  428. version: v0.77.5
  429. - name: Restore forecast report logs cache
  430. id: forecast_report_logs_cache
  431. uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
  432. with:
  433. path: .github/aw/logs
  434. key: ${{ runner.os }}-forecast-report-logs-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}
  435. restore-keys: |
  436. ${{ runner.os }}-forecast-report-logs-${{ github.repository }}-
  437. ${{ runner.os }}-forecast-report-logs-
  438. - name: Generate forecast report
  439. id: generate_forecast_report
  440. shell: bash
  441. env:
  442. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  443. GH_AW_CMD_PREFIX: gh aw
  444. run: |
  445. mkdir -p ./.cache/gh-aw/forecast
  446. ${GH_AW_CMD_PREFIX} logs --repo "${{ github.repository }}" --start-date -30d --count 1500 > /dev/null
  447. if ! compgen -G ".github/aw/logs/run-*/run_summary.json" > /dev/null; then
  448. echo "::error::Missing run summary cache in .github/aw/logs after gh aw logs warm-up; cannot run forecast."
  449. exit 1
  450. fi
  451. set +e
  452. ${GH_AW_CMD_PREFIX} forecast --repo "${{ github.repository }}" --timeout 10 --json 2> >(grep -Fv "forecast is an experimental command and may change without notice" >&2) > ./.cache/gh-aw/forecast/report.json
  453. forecast_exit_code=$?
  454. set -e
  455. if [ "${forecast_exit_code}" -eq 124 ]; then
  456. echo '{"outcome":"timeout","message":"Forecast computation timed out after 10 minutes."}' > ./.cache/gh-aw/forecast/error.json
  457. echo "::error::Forecast computation timed out after 10 minutes."
  458. exit 1
  459. fi
  460. if [ "${forecast_exit_code}" -ne 0 ]; then
  461. echo '{"outcome":"error","message":"Forecast computation failed before producing a report."}' > ./.cache/gh-aw/forecast/error.json
  462. echo "::error::Forecast computation failed with exit code ${forecast_exit_code}."
  463. exit 1
  464. fi
  465. - name: Save forecast report logs cache
  466. if: ${{ always() }}
  467. uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
  468. with:
  469. path: .github/aw/logs
  470. key: ${{ steps.forecast_report_logs_cache.outputs.cache-primary-key }}
  471. - name: Generate forecast issue
  472. if: ${{ always() }}
  473. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  474. env:
  475. FORECAST_STEP_OUTCOME: ${{ steps.generate_forecast_report.outcome }}
  476. with:
  477. github-token: ${{ secrets.GITHUB_TOKEN }}
  478. script: |
  479. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  480. setupGlobals(core, github, context, exec, io, getOctokit);
  481. const { main } = require('${{ runner.temp }}/gh-aw/actions/create_forecast_issue.cjs');
  482. await main();
  483. close_agentic_workflows_issues:
  484. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'close_agentic_workflows_issues' && (!(github.event.repository.fork)) }}
  485. runs-on: ubuntu-slim
  486. permissions:
  487. issues: write
  488. steps:
  489. - name: Setup Scripts
  490. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  491. with:
  492. destination: ${{ runner.temp }}/gh-aw/actions
  493. - name: Check admin/maintainer permissions
  494. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  495. with:
  496. github-token: ${{ secrets.GITHUB_TOKEN }}
  497. script: |
  498. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  499. setupGlobals(core, github, context, exec, io, getOctokit);
  500. const { main } = require('${{ runner.temp }}/gh-aw/actions/check_team_member.cjs');
  501. await main();
  502. - name: Close no-repro agentic-workflows issues
  503. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  504. with:
  505. github-token: ${{ secrets.GITHUB_TOKEN }}
  506. script: |
  507. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  508. setupGlobals(core, github, context, exec, io, getOctokit);
  509. const { main } = require('${{ runner.temp }}/gh-aw/actions/close_agentic_workflows_issues.cjs');
  510. await main();
  511. validate_workflows:
  512. if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.operation == 'validate' && (!(github.event.repository.fork)) }}
  513. runs-on: ubuntu-latest
  514. permissions:
  515. contents: read
  516. issues: write
  517. steps:
  518. - name: Checkout repository
  519. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  520. with:
  521. persist-credentials: false
  522. - name: Setup Scripts
  523. uses: github/gh-aw-actions/setup@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  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: Install gh-aw
  536. uses: github/gh-aw-actions/setup-cli@3ea13c02d765410340d533515cb31a7eef2baaf0 # v0.77.5
  537. with:
  538. version: v0.77.5
  539. - name: Validate workflows and file issue on findings
  540. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
  541. env:
  542. GH_AW_CMD_PREFIX: gh aw
  543. with:
  544. github-token: ${{ secrets.GITHUB_TOKEN }}
  545. script: |
  546. const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
  547. setupGlobals(core, github, context, exec, io, getOctokit);
  548. const { main } = require('${{ runner.temp }}/gh-aw/actions/run_validate_workflows.cjs');
  549. await main();