mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-05-19 13:44:45 +00:00
Make input username and password optional
If user has authenticated to container image registry before running this action, then it's not required to provide username and password in this action Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
002092527f
commit
2c3fb7261b
7 changed files with 49 additions and 84 deletions
16
src/index.ts
16
src/index.ts
|
@ -49,8 +49,8 @@ async function run(): Promise<void> {
|
|||
tagsList.push(DEFAULT_TAG);
|
||||
}
|
||||
const registry = core.getInput(Inputs.REGISTRY, { required: true });
|
||||
const username = core.getInput(Inputs.USERNAME, { required: true });
|
||||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||
const username = core.getInput(Inputs.USERNAME);
|
||||
const password = core.getInput(Inputs.PASSWORD);
|
||||
const tlsVerify = core.getInput(Inputs.TLS_VERIFY);
|
||||
const digestFileInput = core.getInput(Inputs.DIGESTFILE);
|
||||
|
||||
|
@ -158,7 +158,10 @@ async function run(): Promise<void> {
|
|||
|
||||
const registryWithoutTrailingSlash = registry.replace(/\/$/, "");
|
||||
|
||||
const creds = `${username}:${password}`;
|
||||
let creds = "";
|
||||
if (username && password) {
|
||||
creds = `${username}:${password}`;
|
||||
}
|
||||
|
||||
let digestFile = digestFileInput;
|
||||
const imageNameWithTag = `${imageToPush}:${tagsList[0]}`;
|
||||
|
@ -179,8 +182,6 @@ async function run(): Promise<void> {
|
|||
"--quiet",
|
||||
"--digestfile",
|
||||
digestFile,
|
||||
"--creds",
|
||||
creds,
|
||||
imageWithTag,
|
||||
registryPath,
|
||||
];
|
||||
|
@ -194,6 +195,11 @@ async function run(): Promise<void> {
|
|||
args.push(`--tls-verify=${tlsVerify}`);
|
||||
}
|
||||
|
||||
// check if registry creds are provided
|
||||
if (creds) {
|
||||
args.push(`--creds=${creds}`);
|
||||
}
|
||||
|
||||
await execute(await getPodmanPath(), args);
|
||||
core.info(`Successfully pushed "${imageWithTag}" to "${registryPath}"`);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue