Skip to content

Keep runner images up to date with a weekly agentic workflow - #4352

Draft
henrymercer wants to merge 8 commits into
mainfrom
henrymercer/runner-image-list-automation
Draft

henrymercer wants to merge 8 commits into
mainfrom
henrymercer/runner-image-list-automation

Conversation

@henrymercer

@henrymercer henrymercer commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a weekly gh-aw agentic workflow that keeps the GitHub-hosted runner images that our workflows use up to date. That way we add new images, and stop using retiring ones before their brownouts start, rather than finding out when required checks fail.

The workflow's instructions are in .github/workflows/update-runner-images.md, which gh aw compile compiles to update-runner-images.lock.yml. Copilot compares the runner-images PR check with the runner images README and the open announcements in actions/runner-images, and opens a PR if something needs to change. Most weeks, nothing will. It doesn't propose changes that one of its open PRs already makes.

PRs that are still open after two weeks are closed by agentics-maintenance.yml, a daily workflow that gh aw compile generates. Unchecking a PR's expires line keeps it open. The next run proposes the changes from expired PRs again if they're still needed, so a maintainer should close any PR whose changes we don't want. .github/workflows/aw.json turns off the maintenance workflow's manual operations, which we don't use. gh-aw opens an issue when a run fails, and the maintenance workflow closes those issues after a week.

Dependabot skips both generated workflows, since recompiling would revert its updates. gh aw upgrade updates their actions instead.

The workflow doesn't need a PAT. It uses copilot-requests: write for Copilot requests, and opens PRs with GITHUB_TOKEN, so that their workflow runs wait for a maintainer to approve them before they use the repository's secrets. GITHUB_TOKEN can't push changes to workflows, so the CodeQL CI app pushes the PR's branch, using the existing CODEQL_CI_APP_CLIENT_ID variable and CODEQL_CI_APP_PRIVATE_KEY secret. Only the step that mints the token for that push uses the app's key.

Workflows that run on that push don't wait for approval, so:

  • The branch names start with runner-images/, so they don't match the push triggers of the workflows that run on main or release branches.
  • prepare-release.yml and rollback-release.yml run when a branch that changes them is pushed, so the workflow leaves them out of its PRs. As a result, gh-aw puts each PR's changes in a single commit titled "Apply filtered changes".
  • gh-aw's threat detection checks the agent's changes before they're pushed. The workflow asks its model to flag changes that add a workflow or change an existing workflow's triggers. Before the model runs, a step runs pr-checks/check-workflow-changes.ts, which fails if the changes add, delete or replace a workflow, or change anything in an existing one apart from its jobs, comments and formatting. If the model flags a threat, or detection fails, the run fails without pushing the branch. The model also runs in weeks when nothing needs to change, so a detection failure fails those runs too.

The agent runs in gh-aw's sandbox and can't reach GitHub directly. Its GitHub tools hide issues, PRs and comments whose authors aren't owners, members or collaborators of the item's repository, except PRs from branches in that repository and content from GitHub's own bots, such as github-actions[bot]. The authors of the announcements have the CONTRIBUTOR author association, so the workflow saves the announcements, along with the README, before the agent starts. The agent's PR can only change pr-checks/sync.ts and the YAML files in .github/workflows and pr-checks/checks.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Environments:

  • Testing/None - This change does not impact any CodeQL workflows in production.

How did/will you validate this change?

  • Other - I ran the workflow on push from a test branch, with failure issues turned off, and had it open draft PRs against the test branch. With ubuntu-24.04-arm removed from the runner-images check, the agent added it back. Threat detection checked the patch, and the workflow opened Test of the runner images agentic workflow (please ignore) #4322 from a runner-images/ branch, whose workflow runs waited for approval. With windows-2022 removed instead, the agent finished without opening a PR, since I'd just closed an earlier test PR that added it back. I haven't tested PR expiry. After adding pr-checks/check-workflow-changes.ts, I ran the workflow from two more test branches. Without windows-2025 in the runner-images check, the script passed and the workflow opened Test of the runner images agentic workflow (please ignore) #4354. When I also asked the agent to add a workflow, the script failed, and the run ended without pushing a branch. I also tested the script locally against changes that delete a workflow, make an existing workflow run on pushes to runner-images/ branches, or only change jobs and comments. After merging, I'll run the workflow on main.

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Development/testing only - This change cannot cause any failures in production.

How will you know if something goes wrong after this change is released?

  • Other - Failed Update runner images runs, which gh-aw also reports in an issue.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

henrymercer and others added 4 commits November 24, 2026 17:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
`aw.json` turns off the manual operations in the generated maintenance workflow, which this
repository doesn't use.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 13:27
@github-actions github-actions Bot added the size/M Should be of average difficulty to review label Nov 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The instructions lack approval, completion, and dry-run safeguards for sync-checks.ts --apply, which can replace required checks with an incomplete or empty set on main and supported release branches.

3 open issues
What changed in this PR

Adds scheduled automation to keep this repository’s GitHub-hosted runner images current and avoid CI interruptions during image retirements.

Changes:

  • Adds a weekly Copilot workflow that reads image documentation and announcements, then proposes scoped, threat-checked updates.
  • Adds daily cleanup of expired automation PRs and issues, with unused manual maintenance jobs disabled.
  • Integrates generated workflows with required-check exclusions, formatting, Dependabot, and diff-size metadata.
File Description
pr-checks/​excluded.yml Excludes agentic and maintenance jobs from required checks.
pr-checks/​checks/​runner-images.yml Updates comments describing retirement exclusions and automation ownership.
.prettierignore Excludes generated workflow YAML from formatting.
.github/​workflows/​update-runner-images.md Defines the schedule, agent instructions, permissions, and PR safeguards.
.github/​workflows/​update-runner-images.lock.yml Adds the compiled runner-image update workflow.
.github/​workflows/​aw.json Disables unused manual maintenance jobs.
.github/​workflows/​agentics-maintenance.yml Adds generated daily cleanup of expired resources.
.github/​sizeup.yml Excludes generated workflows from PR-size calculations.
.github/​dependabot.yml Skips generated workflows and compiler-managed gh-aw actions.
.github/​aw/​actions-lock.json Pins the gh-aw setup action.
.gitattributes Marks generated workflows for GitHub’s diff presentation.

Review effort: Max (adaptive)

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize this repository for GitHub Agentic Workflows using https://raw.githubusercontent.com/github/gh-aw/main/install.md

henrymercer and others added 3 commits November 25, 2026 14:51
… checks finish

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…s` check

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… more than their jobs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added size/L May be hard to review and removed size/M Should be of average difficulty to review labels Nov 25, 2026
@henrymercer
henrymercer requested an adaptive review from Copilot November 25, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The workflow uses the app’s private key to mint workflow-write tokens even on noop runs, creating unnecessary privileged credentials and risking credential-dependent failures.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Avoid minting privileged tokens on noop runs

.github/​workflows/​update-runner-images.md:101

This step uses the app's private key and mints a workflow-write token even on noop runs, where no branch is pushed. Could it use the checkout's contains(needs.agent.outputs.output_types, 'create_pull_request') guard to avoid unnecessary privileged tokens and credential-dependent failures on those runs? The lock file would also need regeneration with gh aw compile.

3 resolved since last review

Review effort: Max (adaptive)

… for a pull request

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L May be hard to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants