mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
fba1a9de30
* refactor(manager/github-actions): make `extractPackageFile` async As part of follow-up changes we'll need to read `.github/workflows/actions.lock` while extracting, which requires we are an async function. To reduce the diff, we can prefactor this change first. Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io> * feat(manager/github-actions): add support for Actions Lockfiles In June, GitHub announced a public preview for the GitHub Actions lockfile functionality[0]. To add support for this, we can extend our support for GitHub Actions to handle the presence of an `actions.lock` file, and if so, update it after updating other manager files. Although our ideal case would be to have a pure Typescript-based parsing and updating of the `actions.lock`, due to the early nature of the Actions Lockfile syntax, and its lack of stability, we can invoke the `gh actions-lock` extension when updating. After the schema has reached a v1 release, we can then migrate to Typescript. To make sure that the version of the `actions-lock` extension is always version pinned, we can expose a `constraints` to control the version, but allow Renovate to keep the pinned default updated as needed. This doesn't imply that we have support for `lockFileMaintenance`, as we are only updating the lockfile when there is a dependency update, not periodically recreating the lockfile from the current ranges. `gh actions-lock` re-reads every workflow from disk and rewrites the whole lockfile, so it does not fit `updateArtifacts`, which is called once per updated package file. We can instead follow the shape the `npm` manager uses for its lock files, and have `processBranch` invoke this once per branch, after every updated package file has been written to disk. We skip workflows that aren't onboarded to the lockfile, but still run for any other package file, as a local composite action can be a transitive dependency of a workflow which is. `gh actions-lock` rewrites the workflows it manages back to plain refs when it regenerates them, which strips out any inline digest pin: ```diff - uses: actions/setup-java@1bcf9fb12c # v5.4.0 + uses: actions/setup-java@v5.7.0 ``` This would lead to a repository with `pinDigests` set "flip flopping", and would cause a lot of erroneous noise for repository owners. Instead, we can make sure that: - we don't suggest a `pinDigest` for workflows that are managed by the lockfile - digest pinning is still enabled for `docker://` references - already-committed digests are updated when they're present - we only avoid suggesting /new/ digests to be pinned Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com> Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io> Co-authored-by: Claude Fable 5 <jamie.tanna+claude-code@mend.io> [0]: https://github.com/github/actions-lockfile * coverage Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fixup! feat(manager/github-actions): add support for Actions Lockfiles Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import { regEx } from '../../../util/regex.ts';
|
|
import type { OnboardedWorkflows } from './types.ts';
|
|
|
|
/**
|
|
* `gh actions-lock` writes the locked graph of all onboarded workflows, including transitive dependencies of local composite actions, to a single lock file at a fixed location.
|
|
*
|
|
* It is therefore not necessarily a sibling of the package file(s) that are updated.
|
|
*/
|
|
export const actionsLockFile = '.github/workflows/actions.lock';
|
|
|
|
/** Matches GitHub workflow files, not Gitea/Forgejo workflows, `workflow-templates/` or composite action manifests. */
|
|
export const githubWorkflowFileRe = regEx(
|
|
/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/,
|
|
);
|
|
|
|
/** Matches a composite action manifest, which GitHub requires to be named `action.yml` or `action.yaml`. */
|
|
const compositeActionFileRe = regEx(/(^|\/)action\.ya?ml$/);
|
|
|
|
/** Matches anything below a Gitea or Forgejo directory, which `gh actions-lock` never reads. */
|
|
const giteaOrForgejoFileRe = regEx(/(^|\/)\.(?:gitea|forgejo)\//);
|
|
|
|
/**
|
|
* Whether `gh actions-lock` owns the digests in this file, given the workflows which the lock file has onboarded.
|
|
*
|
|
* A repository can deliberately keep a workflow out of the lock file, and those stay ours to pin.
|
|
* A local composite action is never keyed by the lock file, but can be a transitive dependency of a workflow which is onboarded, so the tool rewrites it too.
|
|
* Everything else this manager extracts - Gitea and Forgejo workflows and actions, `workflow-templates/` - is invisible to the tool, so stays ours as well.
|
|
*/
|
|
export function isLockfileManaged(
|
|
packageFile: string,
|
|
onboardedWorkflows: OnboardedWorkflows,
|
|
): boolean {
|
|
if (githubWorkflowFileRe.test(packageFile)) {
|
|
return packageFile in onboardedWorkflows;
|
|
}
|
|
|
|
return (
|
|
compositeActionFileRe.test(packageFile) &&
|
|
!giteaOrForgejoFileRe.test(packageFile)
|
|
);
|
|
}
|