diff --git a/README.md b/README.md index 1ee0601..c42756e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,10 @@ Whether to verify TLS certificates. Default: `true` +### `platform` (optional) + +Specify the architecture of the image to pull + ### `types` (optional) The types of artifacts to build. Can be any type supported by diff --git a/dist/index.js b/dist/index.js index b501397..e576d8d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27326,6 +27326,10 @@ async function build(options) { const podmanArgs = []; const bibArgs = []; podmanArgs.push('run'); + if (options.platform) + { + podmanArgs.push(`--platform ${options.platform}`); + } podmanArgs.push('--rm'); podmanArgs.push('--privileged'); podmanArgs.push('--security-opt label=type:unconfined_t'); @@ -27396,7 +27400,8 @@ async function pullImage(image, tlsVerify) { try { const executible = 'podman'; const tlsFlags = tlsVerify ? '' : '--tls-verify=false'; - await execAsRoot(executible, ['pull', tlsFlags, image].filter((arg) => arg)); + const platformArg = options.platform ? `--platform ${options.platform}` : ''; + await execAsRoot(executible, ['pull', platformArg, tlsFlags, image].filter((arg) => arg)); } catch (error) { coreExports.setFailed(`Failed to pull image ${image}: ${error.message}`); diff --git a/dist/types.d.ts b/dist/types.d.ts index 2362100..f315240 100644 --- a/dist/types.d.ts +++ b/dist/types.d.ts @@ -1,6 +1,7 @@ export interface BootcImageBuilderOptions { configFilePath: string; image: string; + platform?: string; builderImage: string; additionalArgs?: string; chown?: string; diff --git a/package-lock.json b/package-lock.json index 0dc8d66..5b7b632 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "0.0.0", "license": "MIT", "dependencies": { - "@actions/core": "^1.11.1", - "@rollup/rollup-linux-x64-gnu": "*" + "@actions/core": "^1.11.1" }, "devDependencies": { "@eslint/compat": "^1.3.1", diff --git a/src/bib.ts b/src/bib.ts index 71b1796..abb1baf 100644 --- a/src/bib.ts +++ b/src/bib.ts @@ -24,8 +24,8 @@ export async function build( // Pull the required images core.startGroup('Pulling required images') - await pullImage(options.builderImage, options.tlsVerify) - await pullImage(options.image, options.tlsVerify) + await pullImage(options.builderImage, options.tlsVerify, options.platform) + await pullImage(options.image, options.tlsVerify, options.platform) core.endGroup() // Create the output directory @@ -43,6 +43,9 @@ export async function build( podmanArgs.push('run') podmanArgs.push('--rm') podmanArgs.push('--privileged') + if (options.platform) { + podmanArgs.push(`--platform ${options.platform}`) + } podmanArgs.push('--security-opt label=type:unconfined_t') podmanArgs.push( '--volume /var/lib/containers/storage:/var/lib/containers/storage' @@ -126,15 +129,18 @@ export async function build( } } } - -// Pull an image using podman -async function pullImage(image: string, tlsVerify?: boolean): Promise { +async function pullImage( + image: string, + tlsVerify?: boolean, + platform?: string +): Promise { try { const executible = 'podman' const tlsFlags = tlsVerify ? '' : '--tls-verify=false' + const platformFlag = platform ? `--platform ${platform}` : '' await execAsRoot( executible, - ['pull', tlsFlags, image].filter((arg) => arg) + ['pull', tlsFlags, platformFlag, image].filter((arg) => arg) ) } catch (error) { core.setFailed(`Failed to pull image ${image}: ${(error as Error).message}`) diff --git a/src/main.ts b/src/main.ts index 296dd94..b70061e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,6 +12,7 @@ export async function run(): Promise { const configFilePath: string = core.getInput('config-file') const image: string = core.getInput('image') const builderImage: string = core.getInput('builder-image') + const platform: string = core.getInput('platform') || 'linux/amd64' const additionalArgs: string = core.getInput('additional-args') const chown: string = core.getInput('chown') const rootfs: string = core.getInput('rootfs') @@ -34,6 +35,7 @@ export async function run(): Promise { configFilePath, image, builderImage, + platform, additionalArgs, chown, rootfs, diff --git a/src/types.ts b/src/types.ts index d41f2af..b923afb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@ export interface BootcImageBuilderOptions { + platform?: string configFilePath: string image: string builderImage: string