Skip to content

Add imageDigests to output to support multi-arch builds on native runners #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ output

common_lib
lib
dist

17 changes: 9 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ inputs:
required: false
description: One or more comma-separated image tags (defaults to latest)
platform:
require: false
required: false
description: Platforms for which the image should be built. If omitted, defaults to the platform of the GitHub Actions Runner. Multiple platforms should be comma separated.
runCmd:
required: false
description: Specify the command to run after building the dev container image. Can be omitted to skip starting the container.
subFolder:
required: false
description: Specify a child folder (containing a .devcontainer) instead of using the repository root
default:
default: ""
configFile:
required: false
description: Specify the path to a devcontainer.json file instead of using `./.devcontainer/devcontainer.json` or `./.devcontainer.json`
default:
default: ""
checkoutPath:
required: false
description: Specify path to checked out folder if not using default (or for testing with nektos/act)
Expand All @@ -35,7 +35,7 @@ inputs:
description: Control when images are pushed. Options are never, filter, always. For filter (default), images are pushed if the refFilterForPush and eventFilterForPush conditions are met
refFilterForPush:
required: false
default:
default: ""
description: Set the source branches (e.g. refs/heads/main) that are allowed to trigger a push of the dev container image. Leave empty to allow all.
eventFilterForPush:
required: false
Expand All @@ -46,11 +46,11 @@ inputs:
description: Specify environment variables to pass to the docker run command
inheritEnv:
required: false
default: false
default: "false"
description: Inherit all environment variables of the runner CI machine.
skipContainerUserIdUpdate:
required: false
default: false
default: "false"
description: For non-root Dev Containers (i.e. where `remoteUser` is specified), the action attempts to make the container user UID and GID match those of the host user. Set this to true to skip this step (defaults to false)
userDataFolder:
required: false
Expand All @@ -59,16 +59,17 @@ inputs:
required: false
description: Specify additional images to use for build caching
noCache:
type: boolean
required: false
default: false
default: "false"
description: Builds the image with `--no-cache` (takes precedence over `cacheFrom`)
cacheTo:
required: false
description: Specify the image to cache the built image to
outputs:
runCmdOutput:
description: The output of the command specified in the runCmd input
imageDigests:
description: The SHA256 digests of the built images. JSON object with platform keys and digest values.
runs:
using: 'node20'
main: 'github-action/run-main.js'
Expand Down
21 changes: 21 additions & 0 deletions azdo-task/DevcontainersCi/dist/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export interface DevContainerConfig {
workspaceFolder?: string;
remoteUser?: string;
dockerFile?: string;
context?: string;
build?: {
dockerfile?: string;
context?: string;
args?: Record<string, string>;
cacheFrom?: string | string[];
cacheTo?: string | string[];
};
runArgs?: string[];
mounts?: string[];
}
export declare function loadFromFile(filepath: string): Promise<DevContainerConfig>;
export declare function loadFromString(content: string): DevContainerConfig;
export declare function getWorkspaceFolder(config: DevContainerConfig, repoPath: string): string;
export declare function getRemoteUser(config: DevContainerConfig): string;
export declare function getDockerfile(config: DevContainerConfig): string | undefined;
export declare function getContext(config: DevContainerConfig): string | undefined;
59 changes: 59 additions & 0 deletions azdo-task/DevcontainersCi/dist/dev-container-cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { ExecFunction } from './exec';
export interface DevContainerCliError {
outcome: 'error';
code: number;
message: string;
description: string;
}
declare function isCliInstalled(exec: ExecFunction): Promise<boolean>;
declare function installCli(exec: ExecFunction): Promise<boolean>;
export interface DevContainerCliSuccessResult {
outcome: 'success';
}
export interface DevContainerCliBuildResult extends DevContainerCliSuccessResult {
imageDigests?: Record<string, string>;
}
export interface DevContainerCliBuildArgs {
workspaceFolder: string;
configFile: string | undefined;
imageName?: string[];
platform?: string;
additionalCacheFroms?: string[];
userDataFolder?: string;
output?: string;
noCache?: boolean;
cacheTo?: string[];
}
declare function devContainerBuild(args: DevContainerCliBuildArgs, log: (data: string) => void): Promise<DevContainerCliBuildResult | DevContainerCliError>;
export interface DevContainerCliUpResult extends DevContainerCliSuccessResult {
containerId: string;
remoteUser: string;
remoteWorkspaceFolder: string;
}
export interface DevContainerCliUpArgs {
workspaceFolder: string;
configFile: string | undefined;
additionalCacheFroms?: string[];
cacheTo?: string[];
skipContainerUserIdUpdate?: boolean;
env?: string[];
userDataFolder?: string;
additionalMounts?: string[];
}
declare function devContainerUp(args: DevContainerCliUpArgs, log: (data: string) => void): Promise<DevContainerCliUpResult | DevContainerCliError>;
export interface DevContainerCliExecArgs {
workspaceFolder: string;
configFile: string | undefined;
command: string[];
env?: string[];
userDataFolder?: string;
}
declare function devContainerExec(args: DevContainerCliExecArgs, log: (data: string) => void): Promise<number | null>;
export declare const devcontainer: {
build: typeof devContainerBuild;
up: typeof devContainerUp;
exec: typeof devContainerExec;
isCliInstalled: typeof isCliInstalled;
installCli: typeof installCli;
};
export {};
11 changes: 11 additions & 0 deletions azdo-task/DevcontainersCi/dist/docker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ExecFunction } from './exec';
export declare function isDockerBuildXInstalled(exec: ExecFunction): Promise<boolean>;
export declare function buildImage(exec: ExecFunction, imageName: string, imageTag: string | undefined, checkoutPath: string, subFolder: string, skipContainerUserIdUpdate: boolean, cacheFrom: string[], cacheTo: string[]): Promise<string>;
export declare function runContainer(exec: ExecFunction, imageName: string, imageTag: string | undefined, checkoutPath: string, subFolder: string, command: string, envs?: string[], mounts?: string[]): Promise<void>;
export declare function pushImage(exec: ExecFunction, imageName: string, imageTag: string | undefined): Promise<void>;
export interface DockerMount {
type: string;
source: string;
target: string;
}
export declare function parseMount(mountString: string): DockerMount;
2 changes: 2 additions & 0 deletions azdo-task/DevcontainersCi/dist/envvars.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function substituteValues(input: string): string;
export declare function populateDefaults(envs: string[], inheritEnv: boolean): string[];
9 changes: 9 additions & 0 deletions azdo-task/DevcontainersCi/dist/exec.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface ExecResult {
exitCode: number;
stdout: string;
stderr: string;
}
export interface ExecOptions {
silent?: boolean;
}
export type ExecFunction = (command: string, args: string[], options: ExecOptions) => Promise<ExecResult>;
1 change: 1 addition & 0 deletions azdo-task/DevcontainersCi/dist/file.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function getAbsolutePath(inputPath: string, referencePath: string): string;
Loading