mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-04-29 18:19:53 +02:00
Add image-url to the output of the action.
Added Complete URL to the Output of the action. Such that other steps can use the URL for further operations also, Modified README based on the changes. Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
e91c7f612e
commit
4f00df14d1
5 changed files with 42 additions and 21 deletions
16
src/index.ts
16
src/index.ts
|
@ -14,6 +14,12 @@ export async function run(): Promise<void> {
|
|||
const podman = await io.which('podman', true);
|
||||
|
||||
imageToPush = `${imageToPush}:${tag}`;
|
||||
let pushMsg = `Pushing ${imageToPush} to ${registry}`;
|
||||
if (username) {
|
||||
pushMsg += ` as ${username}`;
|
||||
}
|
||||
core.info(pushMsg);
|
||||
|
||||
//check if images exist in podman's local storage
|
||||
const checkImages: CommandResult = await execute(podman, ['images', '--format', 'json']);
|
||||
if (checkImages.succeeded === false) {
|
||||
|
@ -34,12 +40,16 @@ export async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// push image
|
||||
const registryUrl = `${registry.replace(/\/$/, '')}/${imageToPush}`;
|
||||
const push: CommandResult = await execute(podman, ['push', '--quiet', '--creds', `${username}:${password}`, `${imageToPush}`, `${registryUrl}`]);
|
||||
const registryPath = `${registry.replace(/\/$/, '')}/${imageToPush}`;
|
||||
|
||||
const creds: string = `${username}:${password}`;
|
||||
const push: CommandResult = await execute(podman, ['push', '--quiet', '--creds', creds, imageToPush, registryPath]);
|
||||
if (push.succeeded === false) {
|
||||
return Promise.reject(new Error(push.reason));
|
||||
}
|
||||
core.info(`Successfully pushed ${imageToPush} to ${registryUrl}.`);
|
||||
core.info(`Successfully pushed ${imageToPush} to ${registryPath}.`);
|
||||
|
||||
core.setOutput('registry-path', registryPath);
|
||||
}
|
||||
|
||||
async function execute(executable: string, args: string[]): Promise<CommandResult> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue