mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-02-23 10:31:21 +01:00
Update code
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
1b6468c894
commit
6c4ab503eb
8 changed files with 38 additions and 46 deletions
13
.github/workflows/example.yml
vendored
13
.github/workflows/example.yml
vendored
|
@ -9,8 +9,8 @@ env:
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
login:
|
||||||
name: Build and push image to Quay.io
|
name: Login to container image registry
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
@ -25,12 +25,3 @@ jobs:
|
||||||
password: ${{ env.REGISTRY_PASSWORD }}
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
registry: ${{ env.IMAGE_REGISTRY }}
|
registry: ${{ env.IMAGE_REGISTRY }}
|
||||||
logout: true
|
logout: true
|
||||||
|
|
||||||
# - name: Verify
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# pwd
|
|
||||||
# ls $HOME
|
|
||||||
# cd $HOME
|
|
||||||
# tree work
|
|
||||||
# cat ${XDG_RUNTIME_DIR}/containers/auth.json
|
|
||||||
|
|
12
action.yml
12
action.yml
|
@ -1,21 +1,21 @@
|
||||||
name: 'Podman login'
|
name: 'Podman login'
|
||||||
description: 'GitHub Action to login against a container registry'
|
description: 'GitHub Action to login against a container image registry'
|
||||||
author: 'Red Hat'
|
author: 'Red Hat'
|
||||||
branding:
|
branding:
|
||||||
icon: circle
|
icon: circle
|
||||||
color: red
|
color: red
|
||||||
inputs:
|
inputs:
|
||||||
registry:
|
registry:
|
||||||
description: 'Server address of Docker registry. If not set then will default to Docker Hub'
|
description: 'Server URL of the container image registry'
|
||||||
required: false
|
required: true
|
||||||
username:
|
username:
|
||||||
description: 'Username used to log against the Docker registry'
|
description: 'Username to login against the container image registry'
|
||||||
required: false
|
required: false
|
||||||
password:
|
password:
|
||||||
description: 'Password or personal access token used to log against the Docker registry'
|
description: 'Password to login against the container image registry'
|
||||||
required: false
|
required: false
|
||||||
logout:
|
logout:
|
||||||
description: 'Set to true if you want to logout once the workflows completes'
|
description: 'Set to true if you want to logout at the end of the job'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|
||||||
|
|
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
|
@ -4,7 +4,7 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "12"
|
"node": "12"
|
||||||
},
|
},
|
||||||
"description": "GitHub Action to login against a container registry",
|
"description": "GitHub Action to login against a container image registry",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/redhat-actions/podman-login"
|
"url": "https://github.com/redhat-actions/podman-login"
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
// This file was auto-generated by action-io-generator. Do not edit by hand!
|
// This file was auto-generated by action-io-generator. Do not edit by hand!
|
||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
/**
|
/**
|
||||||
* Set to true if you want to logout once the workflows completes
|
* Set to true if you want to logout at the end of the job
|
||||||
* Required: false
|
* Required: false
|
||||||
* Default: "false"
|
* Default: "false"
|
||||||
*/
|
*/
|
||||||
LOGOUT = "logout",
|
LOGOUT = "logout",
|
||||||
/**
|
/**
|
||||||
* Password or personal access token used to log against the Docker registry
|
* Password to login against the container image registry
|
||||||
* Required: false
|
* Required: false
|
||||||
* Default: None.
|
* Default: None.
|
||||||
*/
|
*/
|
||||||
PASSWORD = "password",
|
PASSWORD = "password",
|
||||||
/**
|
/**
|
||||||
* Server address of Docker registry. If not set then will default to Docker Hub
|
* Server URL of the container image registry
|
||||||
* Required: false
|
* Required: true
|
||||||
* Default: None.
|
* Default: None.
|
||||||
*/
|
*/
|
||||||
REGISTRY = "registry",
|
REGISTRY = "registry",
|
||||||
/**
|
/**
|
||||||
* Username used to log against the Docker registry
|
* Username to login against the container image registry
|
||||||
* Required: false
|
* Required: false
|
||||||
* Default: None.
|
* Default: None.
|
||||||
*/
|
*/
|
||||||
|
|
17
src/index.ts
17
src/index.ts
|
@ -8,7 +8,7 @@ import * as io from "@actions/io";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import { getInputs } from "./context";
|
import { getInputs } from "./context";
|
||||||
import { execute } from "./utils";
|
import { execute } from "./utils";
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from "./state-helper";
|
||||||
|
|
||||||
let podmanPath: string | undefined;
|
let podmanPath: string | undefined;
|
||||||
|
|
||||||
|
@ -23,13 +23,14 @@ async function getPodmanPath(): Promise<string> {
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
if (os.platform() !== "linux") {
|
if (os.platform() !== "linux") {
|
||||||
throw new Error("Only supported on linux platform");
|
throw new Error("❌ Only supported on linux platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
registry, username, password, logout,
|
registry, username, password, logout, // eslint-disable-line @typescript-eslint/no-shadow
|
||||||
} = getInputs();
|
} = getInputs();
|
||||||
|
|
||||||
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
|
@ -43,22 +44,18 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
await execute(await getPodmanPath(), args);
|
await execute(await getPodmanPath(), args);
|
||||||
core.info(`✅ Successfully logged in to ${registry}`);
|
core.info(`✅ Successfully logged in to ${registry}`);
|
||||||
|
|
||||||
// if (logout) {
|
|
||||||
// await execute(await getPodmanPath(), [ "logout", registry ]);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout(): Promise<void> {
|
async function logout(): Promise<void> {
|
||||||
if (!stateHelper.logout) {
|
if (!stateHelper.logout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await execute(await getPodmanPath(), [ "logout", "quay.io" ]);
|
await execute(await getPodmanPath(), [ "logout", stateHelper.registry ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateHelper.IsPost) {
|
if (!stateHelper.IsPost) {
|
||||||
run().catch(core.setFailed);;
|
run().catch(core.setFailed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logout().catch(core.setFailed);;
|
logout().catch(core.setFailed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
export const IsPost = !!process.env['STATE_isPost'];
|
/* eslint-disable dot-notation */
|
||||||
// export const registry = process.env['STATE_registry'] || '';
|
export const IsPost = !!process.env["STATE_isPost"];
|
||||||
export const logout = /true/i.test(process.env['STATE_logout'] || '');
|
export const registry = process.env["STATE_registry"] || "";
|
||||||
|
export const logout = /true/i.test(process.env["STATE_logout"] || "");
|
||||||
|
/* eslint-enable dot-notation */
|
||||||
|
|
||||||
// export function setRegistry(registry: string) {
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
// core.saveState('registry', registry);
|
export function setRegistry(registry: string): void {
|
||||||
// }
|
core.saveState("registry", registry);
|
||||||
|
}
|
||||||
|
|
||||||
export function setLogout(logout: string) {
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
core.saveState('logout', logout);
|
export function setLogout(logout: string): void {
|
||||||
|
core.saveState("logout", logout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsPost) {
|
if (!IsPost) {
|
||||||
core.saveState('isPost', 'true');
|
core.saveState("isPost", "true");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue