Files
renovate/lib/modules/manager/github-actions/known-actions/docker-dynamic.ts
Jamie Tanna 2b84f8c13d refactor(manager/github-actions): restructure directory for known-actions (#46248)
As noted in #46242, the `known-actions.ts` file was getting a bit big.

Where we have dynamic extractions, using `transform`, we split these
into a `<datasource>-dynamic.ts` file.

Where we have multiple packages extracted from the same Action, we use
`multiple.ts`.

Per suggestion from Sebastian, we can break this down by the datasource
used by the Action's inputs.

We can also try to enforce the structure of the directories by adding a
test in each file.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-16 11:40:35 +00:00

43 lines
1.5 KiB
TypeScript

import { z } from 'zod/v4';
import { DockerDatasource } from '../../../datasource/docker/index.ts';
import type { ActionSchema, KnownActionConfig } from '../types.ts';
import { parseImageValue, parseValue } from './utils.ts';
const EcsRenderTaskDefinitionWith: ActionSchema = z
.object({ image: z.string().optional() })
.transform(({ image }) => [parseImageValue(image)]);
const renovateGithubActionDefaultImage = 'ghcr.io/renovatebot/renovate';
const RenovateGithubActionWith: ActionSchema = z
.object({
'renovate-version': z.string().optional(),
'renovate-image': z.string().optional(),
})
.transform(({ 'renovate-version': version, 'renovate-image': image }) => {
const [packageName, currentDigest] = (
image ?? renovateGithubActionDefaultImage
).split('@');
return [
{
packageName,
...(currentDigest ? { currentDigest } : {}),
...parseValue(version),
},
];
});
export const dockerDynamicActions: Record<string, KnownActionConfig> = {
// https://github.com/aws-actions/amazon-ecs-render-task-definition
'aws-actions/amazon-ecs-render-task-definition': {
datasource: DockerDatasource.id,
packageName: '', // determined from `image` input
withSchema: EcsRenderTaskDefinitionWith,
},
// https://github.com/renovatebot/github-action
'renovatebot/github-action': {
datasource: DockerDatasource.id,
packageName: '', // determined from `renovate-image` input, if set
withSchema: RenovateGithubActionWith,
},
};