Skip to content

github_actions: pass home hostname to gh-actions-lock - #16504

Open
nodeselector wants to merge 14 commits into
dependabot:mainfrom
nodeselector:nodeselector/gh-actions-lock-hostname
Open

nodeselector wants to merge 14 commits into
dependabot:mainfrom
nodeselector:nodeselector/gh-actions-lock-hostname

Conversation

@nodeselector

@nodeselector nodeselector commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

Dependabot bumps uses: refs today without touching .github/workflows/actions.lock, so every repo using gh-actions-lock gets a PR with a stale lock. This relocks actions.lock alongside the bump using the gh-actions-lock CLI, and makes it work on GHE.com tenants where the home host is not github.com.

Home-host plumbing. The CLI binds every pin with an omitted lockfile hostname to its home host. Core runs it in a temp dir with no git remote, so without help it silently defaults to github.com.

$/ self-repository actions. When a workflow uses uses: $/..., the fetcher pulls every action.yml/action.yaml in the repo and the engine writes them at repo-relative paths. The temp dir has no .git, so every relock sets GH_ACTIONS_LOCK_REPO_ROOT to name the root $/ resolves against.

CLI pin and schema gate. The Dockerfile installs the v0.2.0 release with sha256 checks. v0.0.2 and v0.0.3 are accepted, since the CLI migrates v0.0.2 and always writes v0.0.3. The gate only fires once the lock covers a workflow we're changing.

Exit-1 findings. Exit 1 means the CLI wrote nothing. The finding mapper turns an unresolvable finding (unreachable pin, repo replaced, and so on) into UnresolvableDependency, and anything else into a retryable EngineError. Host-identity 404s become DependencyFileNotResolvable. 5xx, rate-limit 403s and timeouts stay EngineError.

Schema-aware pin hosts. A pinned action binds to its lockfile host instead of probing the tenant, which falls back to github.com on any failure. pinned_hostname reads an omitted hostname as home in v0.0.3 and github.com in v0.0.2, ignores any other host, and matches owner/repo case-insensitively with an exact ref.

Anything you want to highlight for special attention from reviewers?

$/ support fetches every action definition in the repo, not just the ones workflows reference directly, because composites can call each other from anywhere. It's one recursive tree call plus a read per action file, and only when a workflow has a $/ reference. A truncated tree (over 100k entries) can miss composites, which surfaces as an EngineError rather than a wrong lock.

How will you know you've accomplished your goal?

Specs cover each boundary:

  • FileUpdater hands hostname: "tenant.ghe.com" to CliEngine, and the builder passes the tenant host through.
  • CliEngine always passes --hostname and materializes $/ actions under GH_ACTIONS_LOCK_REPO_ROOT. Exit-1 specs cover the finding mapper.
  • Parser specs cover tenant blips, explicit github.com, legacy v0.0.2, foreign hosts and ref case.
  • Fetcher specs cover $/ fetches and ghe.com sources.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:43
@github-actions github-actions Bot added the L: github:actions GitHub Actions label Oct 8, 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 dry-run path still defaults tenant relocks to github.com, and the staging-only source build must be replaced before merging.

3 open findings
What changed in this PR

Adds hostname-aware GitHub Actions lockfile relocking, including *.ghe.com support and schema v0.0.3 compatibility.

Changes:

  • Propagates the repository hostname and selects only its credential.
  • Enables experimental *.ghe.com lockfile handling and maps host errors.
  • Temporarily builds the hostname-aware CLI from source.
File Description
updater/​spec/​dependabot/​dependency_change_builder_spec.rb Tests hostname option propagation.
updater/​lib/​dependabot/​dependency_change_builder.rb Passes the source hostname to file updaters.
github_actions/​spec/​dependabot/​github_actions/​lockfile/​version_gate_spec.rb Covers schema v0.0.3.
github_actions/​spec/​dependabot/​github_actions/​lockfile/​env_spec.rb Tests tenant credential selection.
github_actions/​spec/​dependabot/​github_actions/​lockfile/​cli_engine_spec.rb Tests hostname arguments and identity errors.
github_actions/​spec/​dependabot/​github_actions/​file_fetcher_spec.rb Covers experimental ghe.com fetching.
github_actions/​lib/​dependabot/​github_actions/​lockfile/​version_gate.rb Supports multiple schema versions.
github_actions/​lib/​dependabot/​github_actions/​lockfile/​errors.rb Updates supported-version messaging.
github_actions/​lib/​dependabot/​github_actions/​lockfile/​env.rb Selects credentials for the home host.
github_actions/​lib/​dependabot/​github_actions/​lockfile/​cli_engine.rb Supplies hostname and maps identity failures.
github_actions/​lib/​dependabot/​github_actions/​file_updater.rb Forwards hostname during relocking.
github_actions/​lib/​dependabot/​github_actions/​file_fetcher.rb Gates *.ghe.com lockfiles experimentally.
github_actions/​lib/​dependabot/​github_actions/​constants.rb Adds schema v0.0.3 support.
github_actions/​Dockerfile Builds the unreleased CLI revision from source.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread github_actions/Dockerfile Outdated
Comment thread github_actions/lib/dependabot/github_actions/file_updater.rb
Comment thread updater/spec/dependabot/dependency_change_builder_spec.rb
Builds github/gh-actions-lock#137 at c5ee15d from source; no release
exists for this SHA. Swap back to a release pin before review.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:41
@nodeselector
nodeselector force-pushed the nodeselector/gh-actions-lock-hostname branch from 743c5f2 to 8d124a5 Compare October 8, 2026 21:41

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 Dockerfile still contains the explicitly temporary source build that must return to a checksummed release pin before merge.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:50
@nodeselector
nodeselector force-pushed the nodeselector/gh-actions-lock-hostname branch from 8d124a5 to 9050ba9 Compare October 8, 2026 21:50
@nodeselector
nodeselector marked this pull request as ready for review October 8, 2026 21:53
@nodeselector
nodeselector requested a review from a team as a code owner October 8, 2026 21:53

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 FileUpdater hostname handoff lacks direct regression coverage, and the Dockerfile remains staging-only.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread github_actions/lib/dependabot/github_actions/file_updater.rb
nodeselector and others added 2 commits October 8, 2026 15:02
The engine binds every pin with an omitted lockfile hostname to its home
host. It runs in a temp dir with no git remote, so without --hostname
the home host silently defaults to github.com. Pass --hostname from the
job source and forward only a home-host token. Accept the v0.0.3 schema
the engine now writes, and report lock host-identity failures as
user-actionable rather than engine errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fetch actions.lock for *.ghe.com sources under the existing
github_actions_lockfile experiment, same as github.com.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:07
@nodeselector
nodeselector force-pushed the nodeselector/gh-actions-lock-hostname branch from 9050ba9 to 9b6de3b Compare October 8, 2026 22:07

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 Dockerfile still contains the explicitly temporary source build that must return to a checksummed release pin before merging.

1 open finding

🧠 Review effort: Balanced

@v-kbukum1 v-kbukum1 self-assigned this Oct 9, 2026
@v-kbukum1

Copy link
Copy Markdown
Contributor

Before merge

Worth double-checking

  • Error mapping (lockfile/cli_engine.rb:32): upstream, verifying repository identity also wraps transient errors such as 5xx, 429 and timeouts. Please make sure those don't surface to users as dependency_file_not_resolvable.
  • Deleted workflows (file_updater.rb:85): relocks are scoped to the changed workflows, so pins for removed workflows can stay in the lockfile. On Proxima, VerifyHosts checks every pin. Please confirm that a stale pin can't fail every relock.
  • Lockfile hostname (file_parser.rb:139-146): the parser resolves tenant-first and doesn't read the pin's hostname, while the CLI does. Please confirm this is OK for now, or track it as a follow-up.
  • Lockfile format: relocks write v0.0.3, which older CLI versions (v0.1.6) reject. Please make sure users have a compatible CLI before prod.

If we want to do dry-run for proxima

  • bin/dry-run.rb doesn't pass source_hostname, so Proxima dry-runs default to github.com.

CI: the nuget and pip-compile failures are unrelated.

gh-actions-lock wraps every RepoIDs error in 'verifying repository
identity', so 5xx, rate-limit 403s and timeouts were surfacing as
dependency_file_not_resolvable instead of retryable engine errors.
A pinned action now uses the host recorded in the lockfile (omitted
means the home host) instead of probing the tenant and falling back to
github.com on any failure.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21: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.

🟡 Changes recommended

Legacy v0.0.2 pins are incorrectly rebound from github.com to the tenant home host.

2 open findings

🧠 Review effort: Balanced

Comment thread github_actions/lib/dependabot/github_actions/lockfile/reader.rb Outdated
`$/` composites can live anywhere in the repo and call each other, so the
engine needs every action.yml/action.yaml at its repo-relative path. Fetch
them with one recursive tree call when a workflow uses `$/` and the lock
exists, and name the temp dir as the repo root via GH_ACTIONS_LOCK_REPO_ROOT.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 06: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

Unsupported schemas, case-sensitive refs, and truncated Git trees can currently produce incorrect host binding or repeated relock failures.

3 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported
Previously missed (2)

In code that hasn't changed since last review

Medium severity Reject unsupported lockfile schema versions during host binding

github_actions/​lib/​dependabot/​github_actions/​file_parser.rb:224

This reader is used for host binding without checking its schema version. Consequently, an unsupported future lockfile can redirect parsed dependencies using fields whose semantics this version explicitly does not understand, even when the updater never reaches its later VersionGate check. Ignore unsupported readers here (while leaving the updater responsible for raising when an affected workflow is relocked).

Medium severity Preserve case-sensitive Git refs during lock entry matching

github_actions/​lib/​dependabot/​github_actions/​lockfile/​reader.rb:74

Git refs are case-sensitive, but casecmp? folds the entire owner/repo@ref key. If a lock contains refs that differ only by case (for example @Main and @main), this can select the other entry and bind the dependency to its hostname. Compare only the repository portion case-insensitively and keep the ref comparison exact.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:57

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

Relocking can discard CLI-generated migrations, miss valid self-action syntax, and misassociate case-sensitive refs.

3 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported
Previously missed (3)

In code that hasn't changed since last review

Medium severity Regex misses flow-style and aliased uses declarations

github_actions/​lib/​dependabot/​github_actions/​file_fetcher.rb:97

This source-text regex misses valid flow-style and aliased YAML uses declarations, such as the already-supported steps: [{ uses: $/tools/setup }] form (see github_actions/spec/fixtures/workflow_files/workflow_multiline_flow_separate.yml). In those workflows no action definitions are fetched, so the CLI cannot inspect the self-repository action and relocking fails. Detect self-repository uses through WorkflowFile#uses_declarations (including resolved aliases) rather than a line-oriented regex.

Medium severity Local action migrations are discarded from temporary files

github_actions/​lib/​dependabot/​github_actions/​lockfile/​cli_engine.rb:72

The upgraded CLI migrates uses: ./… to $/… by default and writes those changes into the temporary workflows and composite action files, but this method only reads actions.lock back; all of those source-file edits are discarded. This can return a lock generated from content that is never committed. Disable local-action migration here unless FileUpdater also returns every mutated workflow/action file.

Medium severity Ref matching incorrectly ignores Git ref case

github_actions/​lib/​dependabot/​github_actions/​lockfile/​reader.rb:74

casecmp? also folds the ref, but Git refs are case-sensitive. The CLI canonicalizes only owner/repo while preserving ref case, so a lock entry such as owner/repo@Release can incorrectly supply its hostname for an unpinned owner/repo@release use (or select the wrong entry when both exist). Compare the NWO case-insensitively and the ref exactly.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:32

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

Host matching mishandles case-sensitive refs, and local-action discovery does not scale or handle truncated repository trees.

4 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported

🧠 Review effort: Balanced

Comment thread github_actions/lib/dependabot/github_actions/lockfile/reader.rb Outdated
CodeQL flagged the adjacent \s* runs as polynomial backtracking on
uncontrolled workflow content. Match horizontal whitespace only.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:45

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

Lockfile hostname resolution can select incorrect or untrusted hosts, and truncated trees produce deterministic retryable failures.

5 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported

🧠 Review effort: Balanced

Comment thread github_actions/lib/dependabot/github_actions/lockfile/reader.rb Outdated
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:27

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

Self-action discovery misses valid YAML forms and can deterministically fail on truncated repository trees.

2 open findings
3 resolved since last review
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported
Previously missed (1)

In code that hasn't changed since last review

Medium severity Detect self-repository actions across all valid YAML forms

github_actions/​lib/​dependabot/​github_actions/​constants.rb:28

This raw-line detector misses valid YAML forms such as steps: [{ uses: $/tools/setup }] and quoted keys ("uses": "$/tools/setup"). The parser already supports flow-style uses declarations (github_actions/spec/fixtures/workflow_files/workflow_multiple_actions_flow.yml:7), but here those workflows return no support files, so the CLI runs without the referenced action manifests and reports local-action. Detect self-repository uses from parsed declarations, or otherwise cover all valid YAML forms.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:35

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

Unsupported schemas can resolve against the wrong host, while valid or large self-action repositories may omit required manifests.

2 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported
Previously missed (2)

In code that hasn't changed since last review

Medium severity Detect self-repository actions from parsed workflow declarations

github_actions/​lib/​dependabot/​github_actions/​file_fetcher.rb:97

This raw line regex misses valid YAML forms already supported by WorkflowFile, including uses: >- block scalars, aliases, and flow-style mappings. A workflow using $/... in one of those forms will skip fetching its action manifests, so the relock subprocess cannot resolve the self-repository action. Detect self references from WorkflowFile#uses_declarations instead of the source text.

Medium severity Avoid treating unsupported schema versions as legacy

github_actions/​lib/​dependabot/​github_actions/​lockfile/​reader.rb:84

Unsupported schemas are currently treated as legacy schemas here. For example, VersionGate rejects v0.0.4, but an omitted hostname in that same lockfile is interpreted as github.com during parsing, which can send dependency discovery to the wrong host before the updater reaches the version gate. Return nil for unsupported versions so the existing host probe is used instead.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:48

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 CLI asset is unavailable, and lock parsing plus self-action detection contain correctness gaps.

5 open findings
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported

🧠 Review effort: Balanced

Comment thread github_actions/lib/dependabot/github_actions/constants.rb Outdated
Comment thread github_actions/lib/dependabot/github_actions/lockfile/reader.rb
Comment thread github_actions/lib/dependabot/github_actions/file_fetcher.rb Outdated
…keys

Self-repository detection now uses the parsed uses declarations, so quoted
keys, aliases and block scalars are found. Non-string lockfile keys no longer
raise from pinned_hostname.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:21

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

Relocking can use stale self-action content or be skipped when a composite action is the only changed file.

1 open finding
4 resolved since last review
Files not reviewed (1)
  • sorbet/rbi/shims/github_with_retries.rbi: File type not supported
Previously missed (1)

In code that hasn't changed since last review

Medium severity Self-repository relocking uses stale files and skips workflow updates

github_actions/​lib/​dependabot/​github_actions/​file_updater.rb:88

The self-repository action inputs are not tied to the rewritten files. This list uses original dependency_files, so an updated root composite is relocked using its pre-update content; if that composite is the only changed file, the earlier changed_repository_workflows.empty? return skips relocking altogether. A workflow named .github/workflows/action.yml is also added here and overwrites its rewritten copy because in_repo writes action files second. Overlay updated files by repo path, exclude workflow paths from this list, and let changed closure actions trigger relocking of affected onboarded workflows.

🧠 Review effort: Balanced

@v-kbukum1 v-kbukum1 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.

LGTM

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

L: github:actions GitHub Actions

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants