mirror of
https://github.com/docker/login-action.git
synced 2025-08-17 05:15:50 +08:00
Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
465a07811f | ||
![]() |
360b4b5fef | ||
![]() |
c156700b23 | ||
![]() |
f605cf145e | ||
![]() |
2a93a3eddb | ||
![]() |
422e90f610 | ||
![]() |
bc8c4d08b4 | ||
![]() |
052c2c4268 | ||
![]() |
beabccd65a | ||
![]() |
b56ed1c88d | ||
![]() |
a13e198944 | ||
![]() |
1b469c82ee | ||
![]() |
83e260592e | ||
![]() |
6ba7f31490 | ||
![]() |
5447726540 | ||
![]() |
40891eba8c | ||
![]() |
dcd1f1fe0a | ||
![]() |
713d7298f6 | ||
![]() |
a7ae18608a | ||
![]() |
65b78e6e13 | ||
![]() |
219c305e1c | ||
![]() |
eb81c74b31 | ||
![]() |
eb7654ec33 | ||
![]() |
ec9cdf07d5 | ||
![]() |
d01f5a4fd6 | ||
![]() |
af023e8f62 | ||
![]() |
3da7dc6e2b | ||
![]() |
07119058a1 | ||
![]() |
bc135a1993 | ||
![]() |
f8374000f2 | ||
![]() |
9d3e51f876 | ||
![]() |
9ec69b27e2 | ||
![]() |
7f58925139 | ||
![]() |
980c90b31a | ||
![]() |
add9f8d32e | ||
![]() |
f75d088332 | ||
![]() |
b161681273 |
@@ -2,7 +2,7 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"es2021": true,
|
"es2021": true,
|
||||||
"jest/globals": true
|
"jest": true
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -143,7 +143,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Configure AWS Credentials
|
name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v2
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
@@ -190,7 +190,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Configure AWS Credentials
|
name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v2
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -6,9 +6,6 @@ on:
|
|||||||
- 'master'
|
- 'master'
|
||||||
- 'releases/v*'
|
- 'releases/v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -17,14 +14,9 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
-
|
|
||||||
name: Validate
|
|
||||||
uses: docker/bake-action@v2
|
|
||||||
with:
|
|
||||||
targets: validate
|
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v2
|
uses: docker/bake-action@v3
|
||||||
with:
|
with:
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
|
41
.github/workflows/validate.yml
vendored
Normal file
41
.github/workflows/validate.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: validate
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
targets: ${{ steps.targets.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Targets matrix
|
||||||
|
id: targets
|
||||||
|
run: |
|
||||||
|
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
uses: docker/bake-action@v3
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,11 +1,6 @@
|
|||||||
/.dev
|
|
||||||
node_modules/
|
node_modules/
|
||||||
lib
|
lib
|
||||||
|
|
||||||
# Jetbrains
|
|
||||||
/.idea
|
|
||||||
/*.iml
|
|
||||||
|
|
||||||
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
[](https://github.com/docker/login-action/releases/latest)
|
[](https://github.com/docker/login-action/releases/latest)
|
||||||
[](https://github.com/marketplace/actions/docker-login)
|
[](https://github.com/marketplace/actions/docker-login)
|
||||||
[](https://github.com/docker/login-action/actions?workflow=ci)
|
[](https://github.com/docker/login-action/actions?workflow=ci)
|
||||||
[](https://github.com/docker/login-action/actions?workflow=test)
|
[](https://github.com/docker/login-action/actions?workflow=test)
|
||||||
[](https://codecov.io/gh/docker/login-action)
|
[](https://codecov.io/gh/docker/login-action)
|
||||||
|
|
||||||
## About
|
## About
|
||||||
@@ -107,6 +107,8 @@ jobs:
|
|||||||
password: ${{ secrets.GITLAB_PASSWORD }}
|
password: ${{ secrets.GITLAB_PASSWORD }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you have [Two-Factor Authentication](https://gitlab.com/help/user/profile/account/two_factor_authentication) enabled, use a [Personal Access Token](https://gitlab.com/help/user/profile/personal_access_tokens) instead of a password.
|
||||||
|
|
||||||
### Azure Container Registry (ACR)
|
### Azure Container Registry (ACR)
|
||||||
|
|
||||||
[Create a service principal](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal#create-a-service-principal)
|
[Create a service principal](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal#create-a-service-principal)
|
||||||
|
@@ -7,5 +7,5 @@ test('with password and username getInputs does not throw error', async () => {
|
|||||||
process.env['INPUT_LOGOUT'] = 'true';
|
process.env['INPUT_LOGOUT'] = 'true';
|
||||||
expect(() => {
|
expect(() => {
|
||||||
getInputs();
|
getInputs();
|
||||||
}).not.toThrowError();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
@@ -1,26 +1,21 @@
|
|||||||
import {expect, jest, test} from '@jest/globals';
|
import {expect, jest, test} from '@jest/globals';
|
||||||
import osm = require('os');
|
import osm = require('os');
|
||||||
|
|
||||||
import {run} from '../src/main';
|
import {main} from '../src/main';
|
||||||
import * as docker from '../src/docker';
|
import * as docker from '../src/docker';
|
||||||
import * as stateHelper from '../src/state-helper';
|
import * as stateHelper from '../src/state-helper';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
|
|
||||||
test('errors without username and password', async () => {
|
test('errors without username and password', async () => {
|
||||||
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
||||||
process.env['INPUT_LOGOUT'] = 'true'; // default value
|
process.env['INPUT_LOGOUT'] = 'true'; // default value
|
||||||
const coreSpy = jest.spyOn(core, 'setFailed');
|
await expect(main()).rejects.toThrow(new Error('Username and password required'));
|
||||||
|
|
||||||
await run();
|
|
||||||
expect(coreSpy).toHaveBeenCalledWith('Username and password required');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('successful with username and password', async () => {
|
test('successful with username and password', async () => {
|
||||||
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
||||||
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
|
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
|
||||||
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
|
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
|
||||||
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());
|
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
const username = 'dbowie';
|
const username = 'dbowie';
|
||||||
process.env[`INPUT_USERNAME`] = username;
|
process.env[`INPUT_USERNAME`] = username;
|
||||||
@@ -34,7 +29,7 @@ test('successful with username and password', async () => {
|
|||||||
const logout = false;
|
const logout = false;
|
||||||
process.env['INPUT_LOGOUT'] = String(logout);
|
process.env['INPUT_LOGOUT'] = String(logout);
|
||||||
|
|
||||||
await run();
|
await main();
|
||||||
|
|
||||||
expect(setRegistrySpy).toHaveBeenCalledWith('');
|
expect(setRegistrySpy).toHaveBeenCalledWith('');
|
||||||
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
|
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
|
||||||
@@ -45,8 +40,7 @@ test('calls docker login', async () => {
|
|||||||
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
|
||||||
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
|
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
|
||||||
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
|
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
|
||||||
const dockerSpy = jest.spyOn(docker, 'login');
|
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(() => Promise.resolve());
|
||||||
dockerSpy.mockImplementation(jest.fn());
|
|
||||||
|
|
||||||
const username = 'dbowie';
|
const username = 'dbowie';
|
||||||
process.env[`INPUT_USERNAME`] = username;
|
process.env[`INPUT_USERNAME`] = username;
|
||||||
@@ -63,7 +57,7 @@ test('calls docker login', async () => {
|
|||||||
const logout = true;
|
const logout = true;
|
||||||
process.env['INPUT_LOGOUT'] = String(logout);
|
process.env['INPUT_LOGOUT'] = String(logout);
|
||||||
|
|
||||||
await run();
|
await main();
|
||||||
|
|
||||||
expect(setRegistrySpy).toHaveBeenCalledWith(registry);
|
expect(setRegistrySpy).toHaveBeenCalledWith(registry);
|
||||||
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
|
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
|
||||||
|
17
dist/index.js
generated
vendored
17
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2527
dist/licenses.txt
generated
vendored
2527
dist/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
2
dist/sourcemap-register.js
generated
vendored
2
dist/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,10 +1,29 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-login-action-')).split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
GITHUB_REPOSITORY: 'docker/login-action',
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep)
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
setupFiles: ["dotenv/config"],
|
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
||||||
|
},
|
||||||
|
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
||||||
|
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__tests__/'],
|
||||||
verbose: true
|
verbose: true
|
||||||
}
|
};
|
||||||
|
38
package.json
38
package.json
@@ -28,27 +28,25 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@aws-sdk/client-ecr": "^3.347.1",
|
||||||
"@actions/io": "^1.1.2",
|
"@aws-sdk/client-ecr-public": "^3.347.1",
|
||||||
"@aws-sdk/client-ecr": "^3.186.0",
|
"@docker/actions-toolkit": "^0.2.0",
|
||||||
"@aws-sdk/client-ecr-public": "^3.186.0",
|
"http-proxy-agent": "^7.0.0",
|
||||||
"http-proxy-agent": "^5.0.0",
|
"https-proxy-agent": "^7.0.0"
|
||||||
"https-proxy-agent": "^5.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.11.26",
|
"@types/node": "^16.18.21",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
||||||
"@typescript-eslint/parser": "^5.14.0",
|
"@typescript-eslint/parser": "^5.56.0",
|
||||||
"@vercel/ncc": "^0.33.3",
|
"@vercel/ncc": "^0.36.1",
|
||||||
"dotenv": "^16.0.0",
|
"eslint": "^8.36.0",
|
||||||
"eslint": "^8.11.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
"eslint-plugin-jest": "^26.1.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"jest": "^29.5.0",
|
||||||
"jest": "^27.2.5",
|
"prettier": "^2.8.7",
|
||||||
"prettier": "^2.3.1",
|
"ts-jest": "^29.0.5",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-node": "^10.9.1",
|
||||||
"ts-node": "^10.7.0",
|
"typescript": "^4.9.5"
|
||||||
"typescript": "^4.4.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import * as aws from './aws';
|
import * as aws from './aws';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
||||||
|
|
||||||
export async function login(registry: string, username: string, password: string, ecr: string): Promise<void> {
|
export async function login(registry: string, username: string, password: string, ecr: string): Promise<void> {
|
||||||
if (/true/i.test(ecr) || (ecr == 'auto' && aws.isECR(registry))) {
|
if (/true/i.test(ecr) || (ecr == 'auto' && aws.isECR(registry))) {
|
||||||
@@ -11,15 +11,13 @@ export async function login(registry: string, username: string, password: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function logout(registry: string): Promise<void> {
|
export async function logout(registry: string): Promise<void> {
|
||||||
await exec
|
await Exec.getExecOutput('docker', ['logout', registry], {
|
||||||
.getExecOutput('docker', ['logout', registry], {
|
ignoreReturnCode: true
|
||||||
ignoreReturnCode: true
|
}).then(res => {
|
||||||
})
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
.then(res => {
|
core.warning(res.stderr.trim());
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
}
|
||||||
core.warning(res.stderr.trim());
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
|
export async function loginStandard(registry: string, username: string, password: string): Promise<void> {
|
||||||
@@ -36,18 +34,16 @@ export async function loginStandard(registry: string, username: string, password
|
|||||||
} else {
|
} else {
|
||||||
core.info(`Logging into Docker Hub...`);
|
core.info(`Logging into Docker Hub...`);
|
||||||
}
|
}
|
||||||
await exec
|
await Exec.getExecOutput('docker', loginArgs, {
|
||||||
.getExecOutput('docker', loginArgs, {
|
ignoreReturnCode: true,
|
||||||
ignoreReturnCode: true,
|
silent: true,
|
||||||
silent: true,
|
input: Buffer.from(password)
|
||||||
input: Buffer.from(password)
|
}).then(res => {
|
||||||
})
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
.then(res => {
|
throw new Error(res.stderr.trim());
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
}
|
||||||
throw new Error(res.stderr.trim());
|
core.info(`Login Succeeded!`);
|
||||||
}
|
});
|
||||||
core.info(`Login Succeeded!`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginECR(registry: string, username: string, password: string): Promise<void> {
|
export async function loginECR(registry: string, username: string, password: string): Promise<void> {
|
||||||
@@ -55,17 +51,15 @@ export async function loginECR(registry: string, username: string, password: str
|
|||||||
const regDatas = await aws.getRegistriesData(registry, username, password);
|
const regDatas = await aws.getRegistriesData(registry, username, password);
|
||||||
for (const regData of regDatas) {
|
for (const regData of regDatas) {
|
||||||
core.info(`Logging into ${regData.registry}...`);
|
core.info(`Logging into ${regData.registry}...`);
|
||||||
await exec
|
await Exec.getExecOutput('docker', ['login', '--password-stdin', '--username', regData.username, regData.registry], {
|
||||||
.getExecOutput('docker', ['login', '--password-stdin', '--username', regData.username, regData.registry], {
|
ignoreReturnCode: true,
|
||||||
ignoreReturnCode: true,
|
silent: true,
|
||||||
silent: true,
|
input: Buffer.from(regData.password)
|
||||||
input: Buffer.from(regData.password)
|
}).then(res => {
|
||||||
})
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
.then(res => {
|
throw new Error(res.stderr.trim());
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
}
|
||||||
throw new Error(res.stderr.trim());
|
core.info('Login Succeeded!');
|
||||||
}
|
});
|
||||||
core.info('Login Succeeded!');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
src/main.ts
25
src/main.ts
@@ -1,28 +1,21 @@
|
|||||||
import * as core from '@actions/core';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
|
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
import * as docker from './docker';
|
import * as docker from './docker';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function main(): Promise<void> {
|
||||||
try {
|
const input: context.Inputs = context.getInputs();
|
||||||
const input: context.Inputs = context.getInputs();
|
stateHelper.setRegistry(input.registry);
|
||||||
stateHelper.setRegistry(input.registry);
|
stateHelper.setLogout(input.logout);
|
||||||
stateHelper.setLogout(input.logout);
|
await docker.login(input.registry, input.username, input.password, input.ecr);
|
||||||
await docker.login(input.registry, input.username, input.password, input.ecr);
|
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout(): Promise<void> {
|
async function post(): Promise<void> {
|
||||||
if (!stateHelper.logout) {
|
if (!stateHelper.logout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await docker.logout(stateHelper.registry);
|
await docker.logout(stateHelper.registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateHelper.IsPost) {
|
actionsToolkit.run(main, post);
|
||||||
run();
|
|
||||||
} else {
|
|
||||||
logout();
|
|
||||||
}
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
export const IsPost = !!process.env['STATE_isPost'];
|
|
||||||
export const registry = process.env['STATE_registry'] || '';
|
export const registry = process.env['STATE_registry'] || '';
|
||||||
export const logout = /true/i.test(process.env['STATE_logout'] || '');
|
export const logout = /true/i.test(process.env['STATE_logout'] || '');
|
||||||
|
|
||||||
@@ -11,7 +10,3 @@ export function setRegistry(registry: string) {
|
|||||||
export function setLogout(logout: boolean) {
|
export function setLogout(logout: boolean) {
|
||||||
core.saveState('logout', logout);
|
core.saveState('logout', logout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsPost) {
|
|
||||||
core.saveState('isPost', 'true');
|
|
||||||
}
|
|
||||||
|
@@ -1,19 +1,21 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"esModuleInterop": true,
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
"./__tests__/**/*",
|
||||||
|
"./lib/**/*",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"**/*.test.ts",
|
|
||||||
"jest.config.ts"
|
"jest.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user