mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-02-23 02:21:22 +01:00
Add feature to pass extra args when pushing image (#19)
If a user wants to pass few extra args to push command when pushing image, then they can pass using 'extra-args' input parameter. Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
e7b5c08b38
commit
870f44bc9b
7 changed files with 41 additions and 3 deletions
2
.github/workflows/verify-push.yaml
vendored
2
.github/workflows/verify-push.yaml
vendored
|
@ -92,6 +92,8 @@ jobs:
|
|||
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
extra-args: |
|
||||
--disable-content-trust
|
||||
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
|
|
11
README.md
11
README.md
|
@ -68,7 +68,16 @@ Refer to the [`podman push`](http://docs.podman.io/en/latest/markdown/podman-man
|
|||
<td>digestfile</td>
|
||||
<td>No</td>
|
||||
<td>After copying the image, write the digest of the resulting image to the file. By default, the filename will be determined from the image and tag.
|
||||
The contents of this file are the <code>digest</code> output.
|
||||
The contents of this file are the <code>digest</code> output.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>extra-args</td>
|
||||
<td>No</td>
|
||||
<td>Extra args to be passed to podman push.
|
||||
Separate arguments by newline. Do not use quotes.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
## Action Outputs
|
||||
|
|
|
@ -31,6 +31,11 @@ inputs:
|
|||
By default, the filename will be determined from the image and tag.
|
||||
The contents of this file are the digest output.
|
||||
required: false
|
||||
extra-args:
|
||||
description: |
|
||||
Extra args to be passed to podman push.
|
||||
Separate arguments by newline. Do not use quotes - @actions/exec will do the quoting for you.
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
digest:
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
14
src/index.ts
14
src/index.ts
|
@ -3,6 +3,7 @@ import * as exec from "@actions/exec";
|
|||
import * as io from "@actions/io";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { splitByNewline } from "./util";
|
||||
|
||||
interface ExecResult {
|
||||
exitCode: number;
|
||||
|
@ -44,6 +45,15 @@ async function run(): Promise<void> {
|
|||
const tlsVerify = core.getInput("tls-verify");
|
||||
const digestFileInput = core.getInput("digestfile");
|
||||
|
||||
const inputExtraArgsStr = core.getInput("extra-args");
|
||||
let podmanExtraArgs: string[] = [];
|
||||
if (inputExtraArgsStr) {
|
||||
// transform the array of lines into an array of arguments
|
||||
// by splitting over lines, then over spaces, then trimming.
|
||||
const lines = splitByNewline(inputExtraArgsStr);
|
||||
podmanExtraArgs = lines.flatMap((line) => line.split(" ")).map((arg) => arg.trim());
|
||||
}
|
||||
|
||||
imageToPush = `${imageInput}`;
|
||||
const registryPathList: string[] = [];
|
||||
|
||||
|
@ -159,6 +169,10 @@ async function run(): Promise<void> {
|
|||
registryPath,
|
||||
];
|
||||
|
||||
if (podmanExtraArgs.length > 0) {
|
||||
args.push(...podmanExtraArgs);
|
||||
}
|
||||
|
||||
// check if tls-verify is not set to null
|
||||
if (tlsVerify) {
|
||||
args.push(`--tls-verify=${tlsVerify}`);
|
||||
|
|
8
src/util.ts
Normal file
8
src/util.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/***************************************************************************************************
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE file in the project root for license information.
|
||||
**************************************************************************************************/
|
||||
|
||||
export function splitByNewline(s: string): string[] {
|
||||
return s.split(/\r?\n/);
|
||||
}
|
Loading…
Add table
Reference in a new issue