mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-04-02 07:07:46 +02:00
Compare commits
18 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4934294ad0 | ||
![]() |
1cfc5d852e | ||
![]() |
bcf6f9c330 | ||
![]() |
a7d8d3e644 | ||
![]() |
9184318aae | ||
![]() |
8cb6c181aa | ||
![]() |
7283c5d4ff | ||
![]() |
f15701c1a2 | ||
![]() |
9fec908dba | ||
![]() |
f7d3f4f147 | ||
![]() |
097e0bb4d1 | ||
![]() |
632d91dfe1 | ||
![]() |
58898ff661 | ||
![]() |
9088ccefea | ||
![]() |
8a0c05b53e | ||
![]() |
439023eb75 | ||
![]() |
34f135348d | ||
![]() |
43f863be90 |
18 changed files with 3520 additions and 5330 deletions
4
.github/install_latest_podman.sh
vendored
4
.github/install_latest_podman.sh
vendored
|
@ -1,7 +1,3 @@
|
||||||
# https://podman.io/getting-started/installation
|
|
||||||
. /etc/os-release
|
|
||||||
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
|
|
||||||
curl -sSfL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y upgrade
|
sudo apt-get -y upgrade
|
||||||
sudo apt-get -y install podman
|
sudo apt-get -y install podman
|
||||||
|
|
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
|
@ -8,21 +8,21 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Run ESLint
|
name: Run ESLint
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
|
|
||||||
check-dist:
|
check-dist:
|
||||||
name: Check Distribution
|
name: Check Distribution
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
BUNDLE_FILE: "dist/index.js"
|
BUNDLE_FILE: "dist/index.js"
|
||||||
BUNDLE_COMMAND: "npm run bundle"
|
BUNDLE_COMMAND: "npm run bundle"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install
|
- name: Install
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
@ -35,11 +35,11 @@ jobs:
|
||||||
|
|
||||||
check-inputs-outputs:
|
check-inputs-outputs:
|
||||||
name: Check Input and Output enums
|
name: Check Input and Output enums
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
IO_FILE: ./src/generated/inputs-outputs.ts
|
IO_FILE: ./src/generated/inputs-outputs.ts
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
13
.github/workflows/example.yml
vendored
13
.github/workflows/example.yml
vendored
|
@ -15,7 +15,7 @@ env:
|
||||||
jobs:
|
jobs:
|
||||||
podman-pull:
|
podman-pull:
|
||||||
name: Log in and pull image with Podman
|
name: Log in and pull image with Podman
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -23,7 +23,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install latest podman
|
- name: Install latest podman
|
||||||
if: matrix.install_latest
|
if: matrix.install_latest
|
||||||
|
@ -36,20 +36,21 @@ 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 }}
|
||||||
|
|
||||||
buildah-pull:
|
buildah-pull:
|
||||||
name: Log in and pull image with Buildah
|
name: Log in and pull image with Buildah
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
install_latest: [ true, false ]
|
install_latest: [ true, false ]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install latest podman
|
- name: Install latest podman
|
||||||
if: matrix.install_latest
|
if: matrix.install_latest
|
||||||
|
@ -68,14 +69,14 @@ jobs:
|
||||||
|
|
||||||
docker-pull:
|
docker-pull:
|
||||||
name: Log in and pull image with Docker
|
name: Log in and pull image with Docker
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
install_latest: [ true, false ]
|
install_latest: [ true, false ]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install latest podman
|
- name: Install latest podman
|
||||||
if: matrix.install_latest
|
if: matrix.install_latest
|
||||||
|
|
4
.github/workflows/link_check.yml
vendored
4
.github/workflows/link_check.yml
vendored
|
@ -12,9 +12,9 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
markdown-link-check:
|
markdown-link-check:
|
||||||
name: Check links in markdown
|
name: Check links in markdown
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: gaurav-nelson/github-action-markdown-link-check@v1
|
- uses: gaurav-nelson/github-action-markdown-link-check@v1
|
||||||
with:
|
with:
|
||||||
use-verbose-mode: true
|
use-verbose-mode: true
|
||||||
|
|
35
.github/workflows/security_scan.yml
vendored
Normal file
35
.github/workflows/security_scan.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
name: Vulnerability Scan with CRDA
|
||||||
|
on:
|
||||||
|
# push:
|
||||||
|
workflow_dispatch:
|
||||||
|
# pull_request_target:
|
||||||
|
# types: [ assigned, opened, synchronize, reopened, labeled, edited ]
|
||||||
|
# schedule:
|
||||||
|
# - cron: '0 0 * * *' # every day at midnight
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
crda-scan:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
name: Scan project vulnerability with CRDA
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install CRDA
|
||||||
|
uses: redhat-actions/openshift-tools-installer@v1
|
||||||
|
with:
|
||||||
|
source: github
|
||||||
|
github_pat: ${{ github.token }}
|
||||||
|
crda: "latest"
|
||||||
|
|
||||||
|
- name: CRDA Scan
|
||||||
|
id: scan
|
||||||
|
uses: redhat-actions/crda@v1
|
||||||
|
with:
|
||||||
|
crda_key: ${{ secrets.CRDA_KEY }}
|
||||||
|
fail_on: never
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
out/
|
out/
|
||||||
|
.idea/
|
||||||
|
|
22
CHANGELOG.md
22
CHANGELOG.md
|
@ -1,14 +1,24 @@
|
||||||
# podman-login Changelog
|
# podman-login Changelog
|
||||||
|
|
||||||
|
## v1.7
|
||||||
|
- Update action to run on Node20.https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
|
||||||
|
|
||||||
|
## v1.6
|
||||||
|
- Update action/core dependency to 1.10.0
|
||||||
|
|
||||||
|
## v1.5
|
||||||
|
- Update action to run on Node16. https://github.blog/changelog/2022-05-20-actions-can-now-run-in-a-node-js-16-runtime/
|
||||||
|
|
||||||
|
## v1.4
|
||||||
|
- Add ability to login to AWS ECR repositories. More details at https://github.com/redhat-actions/podman-login/issues/23
|
||||||
|
|
||||||
|
## v1.3
|
||||||
|
- Add support to provide custom auth file path instead of using default ones set by podman. More details [here](https://github.com/redhat-actions/podman-login/issues/19).
|
||||||
|
- Add `--verbose` flag in the login command that will give more detailed output.
|
||||||
|
|
||||||
## v1.2
|
## v1.2
|
||||||
- Add ability to pull image from docker after login. https://github.com/redhat-actions/podman-login/issues/15
|
- Add ability to pull image from docker after login. https://github.com/redhat-actions/podman-login/issues/15
|
||||||
|
|
||||||
## v1.1.2
|
|
||||||
- Use `XDG_RUNTIME_DIR` if set for podman auth file
|
|
||||||
|
|
||||||
## v1.1.1
|
|
||||||
- Throw an error if required inputs are not provided
|
|
||||||
|
|
||||||
## v1.1
|
## v1.1
|
||||||
- Set environment variable `REGISTRY_AUTH_FILE` with the generated auth file to work with buildah
|
- Set environment variable `REGISTRY_AUTH_FILE` with the generated auth file to work with buildah
|
||||||
|
|
||||||
|
|
30
README.md
30
README.md
|
@ -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,32 @@ 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)
|
It is also possible to login to AWS ECR repositories:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Log in to ECR
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_USER: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
IMAGE_REGISTRY: 123456789012.dkr.ecr.eu-west-1.amazonaws.com
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
login:
|
||||||
|
name: Log in to AWS ECR Registry
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Log in to AWS ECR
|
||||||
|
uses: redhat-actions/podman-login@v1
|
||||||
|
with:
|
||||||
|
username: ${{ env.REGISTRY_USER }}
|
||||||
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
|
registry: ${{ env.IMAGE_REGISTRY }}
|
||||||
|
|
||||||
|
# Now you can push images, and pull private ones, from ECR.
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -22,6 +25,6 @@ inputs:
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
post: 'dist/index.js'
|
post: 'dist/index.js'
|
||||||
|
|
17
dist/index.js
vendored
17
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
3911
dist/sourcemap-register.js
vendored
3911
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
4665
package-lock.json
generated
4665
package-lock.json
generated
File diff suppressed because it is too large
Load diff
29
package.json
29
package.json
|
@ -2,7 +2,7 @@
|
||||||
"name": "podman-login",
|
"name": "podman-login",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "12"
|
"node": "20"
|
||||||
},
|
},
|
||||||
"description": "GitHub Action to log in against a container image registry",
|
"description": "GitHub Action to log in against a container image registry",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -14,25 +14,28 @@
|
||||||
"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",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.0.2"
|
"@actions/io": "^1.1.3",
|
||||||
|
"@aws-sdk/client-ecr": "^3.535.0",
|
||||||
|
"@aws-sdk/util-base64": "^3.310.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@redhat-actions/action-io-generator": "^1.5.0",
|
"@redhat-actions/action-io-generator": "^1.5.0",
|
||||||
"@redhat-actions/eslint-config": "^1.2.11",
|
"@redhat-actions/eslint-config": "^1.3.2",
|
||||||
"@redhat-actions/tsconfig": "^1.1.1",
|
"@redhat-actions/tsconfig": "^1.2.0",
|
||||||
"@types/node": "^12",
|
"@types/node": "^20",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.14.1",
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||||
"@typescript-eslint/parser": "^4.14.1",
|
"@typescript-eslint/parser": "^7.2.0",
|
||||||
"@vercel/ncc": "^0.25.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^7.18.0",
|
"eslint": "^8.57.0",
|
||||||
"typescript": "^4.0.5"
|
"typescript": "^5.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
54
src/ecr.ts
Normal file
54
src/ecr.ts
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
import { ECR } from "@aws-sdk/client-ecr";
|
||||||
|
|
||||||
|
const ecrRegistryRegex = /^(([0-9]{12})\.dkr\.ecr\.(.+)\.amazonaws\.com(.cn)?)(\/([^:]+)(:.+)?)?$/;
|
||||||
|
|
||||||
|
export interface ECRData {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isECR(registry: string): boolean {
|
||||||
|
return ecrRegistryRegex.test(registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRegion(registry: string): string {
|
||||||
|
const matches = registry.match(ecrRegistryRegex);
|
||||||
|
if (!matches) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return matches[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAccountID(registry: string): string {
|
||||||
|
const matches = registry.match(ecrRegistryRegex);
|
||||||
|
if (!matches) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getECRToken(registry: string, username: string, password: string): Promise<ECRData> {
|
||||||
|
const ecr = new ECR({
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: username,
|
||||||
|
secretAccessKey: password,
|
||||||
|
},
|
||||||
|
region: getRegion(registry),
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await ecr.getAuthorizationToken({ registryIds: [ getAccountID(registry) ] });
|
||||||
|
if (!Array.isArray(response.authorizationData) || response.authorizationData.length === 0) {
|
||||||
|
throw new Error("Unable to fetch ECR credentials from AWS!");
|
||||||
|
}
|
||||||
|
const tokenString = Buffer.from(response.authorizationData[0].authorizationToken || "", "base64").toString("utf-8");
|
||||||
|
const ecrCredentials = tokenString.split(":", 2);
|
||||||
|
|
||||||
|
// Hide auth token in actions logs
|
||||||
|
core.setSecret(ecrCredentials[1]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
username: ecrCredentials[0],
|
||||||
|
password: ecrCredentials[1],
|
||||||
|
};
|
||||||
|
}
|
|
@ -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'
|
||||||
|
|
35
src/index.ts
35
src/index.ts
|
@ -8,6 +8,7 @@ import { promises as fs } from "fs";
|
||||||
import * as io from "@actions/io";
|
import * as io from "@actions/io";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
import * as ecr from "./ecr";
|
||||||
import { execute, getDockerConfigJson } from "./utils";
|
import { execute, getDockerConfigJson } from "./utils";
|
||||||
import * as stateHelper from "./state-helper";
|
import * as stateHelper from "./state-helper";
|
||||||
import { Inputs } from "./generated/inputs-outputs";
|
import { Inputs } from "./generated/inputs-outputs";
|
||||||
|
@ -31,9 +32,17 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
registry = core.getInput(Inputs.REGISTRY, { required: true });
|
registry = core.getInput(Inputs.REGISTRY, { required: true });
|
||||||
const username = core.getInput(Inputs.USERNAME, { required: true });
|
let username = core.getInput(Inputs.USERNAME, { required: true });
|
||||||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
let 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);
|
||||||
|
|
||||||
|
if (ecr.isECR(registry)) {
|
||||||
|
core.info(`💡 Detected ${registry} as an ECR repository`);
|
||||||
|
const ECRData = await ecr.getECRToken(registry, username, password);
|
||||||
|
username = ECRData.username;
|
||||||
|
password = ECRData.password;
|
||||||
|
}
|
||||||
|
|
||||||
stateHelper.setRegistry(registry);
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
|
@ -46,17 +55,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 {
|
||||||
|
// process.getuid might be undefined
|
||||||
|
let authFileDir = path.join("/", "tmp", `podman-run-${process.getuid ? process.getuid() : null}`);
|
||||||
|
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);
|
||||||
|
|
|
@ -69,5 +69,6 @@ export async function execute(
|
||||||
|
|
||||||
export async function getDockerConfigJson(): Promise<string> {
|
export async function getDockerConfigJson(): Promise<string> {
|
||||||
const dockerConfigPath = path.join(os.homedir(), ".docker", "config.json");
|
const dockerConfigPath = path.join(os.homedir(), ".docker", "config.json");
|
||||||
return fs.readFile(dockerConfigPath, "utf-8");
|
return fs.readFile(dockerConfigPath, "utf-8")
|
||||||
|
.catch((err) => { if (err.code === "ENOENT") { return `{"auths":{}}`; } throw err; });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue