mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-02-23 02:21:22 +01:00
Add auth_file_path input and --verbose flag (#21)
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
43f863be90
commit
34f135348d
8 changed files with 34 additions and 9 deletions
1
.github/workflows/example.yml
vendored
1
.github/workflows/example.yml
vendored
|
@ -36,6 +36,7 @@ jobs:
|
||||||
username: ${{ env.REGISTRY_USER }}
|
username: ${{ env.REGISTRY_USER }}
|
||||||
password: ${{ env.REGISTRY_PASSWORD }}
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
registry: ${{ env.IMAGE_REGISTRY }}
|
registry: ${{ env.IMAGE_REGISTRY }}
|
||||||
|
auth_file_path: ./auth/auth.json
|
||||||
|
|
||||||
- name: Pull image with Podman
|
- name: Pull image with Podman
|
||||||
run: podman pull ${{ env.IMAGE_PATH }}
|
run: podman pull ${{ env.IMAGE_PATH }}
|
||||||
|
|
|
@ -26,6 +26,7 @@ This action only runs on `Linux`, as it uses [podman](https://github.com/contain
|
||||||
| username | Username to log in against the container image registry. | **Must be provided**
|
| username | Username to log in against the container image registry. | **Must be provided**
|
||||||
| password | Password, encrypted password, or access token for `username`. | **Must be provided**
|
| password | Password, encrypted password, or access token for `username`. | **Must be provided**
|
||||||
| logout | By default, the action logs out of the container image registry at the end of the job (for self-hosted runners). Set this to `false` to disable this behaviour. | `true`
|
| logout | By default, the action logs out of the container image registry at the end of the job (for self-hosted runners). Set this to `false` to disable this behaviour. | `true`
|
||||||
|
| auth_file_path | Path of the authentication file, this will override the default auth file path in podman | Default set in podman |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -84,5 +85,5 @@ jobs:
|
||||||
# Now you can push images, and pull private ones, from ghcr.io.
|
# Now you can push images, and pull private ones, from ghcr.io.
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to the [GitHub documentation](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context)
|
Refer to the [GitHub documentation](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context) <!-- markdown-link-check-disable-line -->
|
||||||
for information about the `github` context object.
|
for information about the `github` context object.
|
||||||
|
|
|
@ -14,6 +14,9 @@ inputs:
|
||||||
password:
|
password:
|
||||||
description: 'Password, encrypted password, or access token for username'
|
description: 'Password, encrypted password, or access token for username'
|
||||||
required: true
|
required: true
|
||||||
|
auth_file_path:
|
||||||
|
description: 'Path of the authentication file, this will override the default auth file path in podman'
|
||||||
|
required: false
|
||||||
logout:
|
logout:
|
||||||
description: |
|
description: |
|
||||||
'By default, the action logs out of the container image registry at the end
|
'By default, the action logs out of the container image registry at the end
|
||||||
|
|
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,7 +14,8 @@
|
||||||
"compile": "tsc -p .",
|
"compile": "tsc -p .",
|
||||||
"bundle": "ncc build src/index.ts --source-map --minify",
|
"bundle": "ncc build src/index.ts --source-map --minify",
|
||||||
"clean": "rm -rf out/ dist/",
|
"clean": "rm -rf out/ dist/",
|
||||||
"lint": "eslint . --max-warnings=0"
|
"lint": "eslint . --max-warnings=0",
|
||||||
|
"generate-ios": "npx action-io-generator -w -o ./src/generated/inputs-outputs.ts"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Red Hat",
|
"author": "Red Hat",
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
// 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 {
|
||||||
|
/**
|
||||||
|
* Path of the authentication file, this will override the default auth file path in podman
|
||||||
|
* Required: false
|
||||||
|
* Default: None.
|
||||||
|
*/
|
||||||
|
AUTH_FILE_PATH = "auth_file_path",
|
||||||
/**
|
/**
|
||||||
* 'By default, the action logs out of the container image registry at the end
|
* 'By default, the action logs out of the container image registry at the end
|
||||||
* of the job (for self-hosted runners). Set this to false to disable this behaviour'
|
* of the job (for self-hosted runners). Set this to false to disable this behaviour'
|
||||||
|
|
23
src/index.ts
23
src/index.ts
|
@ -34,6 +34,7 @@ async function run(): Promise<void> {
|
||||||
const username = core.getInput(Inputs.USERNAME, { required: true });
|
const username = core.getInput(Inputs.USERNAME, { required: true });
|
||||||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||||
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
||||||
|
const authFilePath = core.getInput(Inputs.AUTH_FILE_PATH);
|
||||||
|
|
||||||
stateHelper.setRegistry(registry);
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
|
@ -46,17 +47,29 @@ async function run(): Promise<void> {
|
||||||
"-p",
|
"-p",
|
||||||
password,
|
password,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
args.push("--verbose");
|
||||||
|
if (authFilePath) {
|
||||||
|
args.push(`--authfile=${authFilePath}`);
|
||||||
|
}
|
||||||
await execute(await getPodmanPath(), args);
|
await execute(await getPodmanPath(), args);
|
||||||
core.info(`✅ Successfully logged in to ${registry} as ${username}`);
|
core.info(`✅ Successfully logged in to ${registry} as ${username}`);
|
||||||
|
|
||||||
// Setting REGISTRY_AUTH_FILE environment variable as buildah needs
|
// Setting REGISTRY_AUTH_FILE environment variable as buildah needs
|
||||||
// this environment variable to point to registry auth file
|
// this environment variable to point to registry auth file
|
||||||
let authFileDir = path.join("/", "tmp", `podman-run-${process.getuid()}`);
|
|
||||||
if (process.env.XDG_RUNTIME_DIR) {
|
let podmanAuthFilePath;
|
||||||
authFileDir = process.env.XDG_RUNTIME_DIR;
|
if (authFilePath) {
|
||||||
|
podmanAuthFilePath = authFilePath;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let authFileDir = path.join("/", "tmp", `podman-run-${process.getuid()}`);
|
||||||
|
if (process.env.XDG_RUNTIME_DIR) {
|
||||||
|
authFileDir = process.env.XDG_RUNTIME_DIR;
|
||||||
|
}
|
||||||
|
podmanAuthFilePath = path.join(authFileDir,
|
||||||
|
"containers", "auth.json");
|
||||||
}
|
}
|
||||||
const podmanAuthFilePath = path.join(authFileDir,
|
|
||||||
"containers", "auth.json");
|
|
||||||
const REGISTRY_AUTH_ENVVAR = "REGISTRY_AUTH_FILE";
|
const REGISTRY_AUTH_ENVVAR = "REGISTRY_AUTH_FILE";
|
||||||
core.info(`Exporting ${REGISTRY_AUTH_ENVVAR}=${podmanAuthFilePath}`);
|
core.info(`Exporting ${REGISTRY_AUTH_ENVVAR}=${podmanAuthFilePath}`);
|
||||||
core.exportVariable(REGISTRY_AUTH_ENVVAR, podmanAuthFilePath);
|
core.exportVariable(REGISTRY_AUTH_ENVVAR, podmanAuthFilePath);
|
||||||
|
|
Loading…
Add table
Reference in a new issue