First commit 🚀

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
divyansh42 2021-03-30 18:57:12 +05:30
commit 565d575198
20 changed files with 6476 additions and 0 deletions

47
src/index.ts Normal file
View file

@ -0,0 +1,47 @@
/***************************************************************************************************
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
**************************************************************************************************/
import * as core from "@actions/core";
import * as io from "@actions/io";
import * as os from "os";
import { getInputs } from "./context";
import { execute } from "./utils";
let podmanPath: string | undefined;
async function getPodmanPath(): Promise<string> {
if (podmanPath == null) {
podmanPath = await io.which("podman", true);
await execute(podmanPath, [ "version" ]);
}
return podmanPath;
}
async function run(): Promise<void> {
if (os.platform() !== "linux") {
throw new Error("Only supported on linux platform");
}
const { registry, username, password } = getInputs();
const args = [
"login",
registry,
"-u",
username,
"-p",
password,
];
try {
await execute(await getPodmanPath(), args);
core.info(`✅ Successfully logged in to ${registry}`);
}
catch (err) {
core.error(`Failed to login to ${registry}`);
}
}
run().catch(core.setFailed);