Compare commits

...

18 Commits

Author SHA1 Message Date
CrazyMax
49ed152c8e Merge pull request #161 from crazy-max/node16-runtime
Node 16 as default runtime
2022-05-05 18:59:26 +02:00
CrazyMax
b61a9ce7bd Node 16 as default runtime
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-05-04 15:17:49 +02:00
CrazyMax
3a136a8631 Merge pull request #182 from docker/dependabot/npm_and_yarn/https-proxy-agent-5.0.1
Bump https-proxy-agent from 5.0.0 to 5.0.1
2022-04-28 07:51:49 +02:00
CrazyMax
b312880b69 Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-04-28 07:50:23 +02:00
dependabot[bot]
795794e081 Bump https-proxy-agent from 5.0.0 to 5.0.1
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/5.0.0...5.0.1)

---
updated-dependencies:
- dependency-name: https-proxy-agent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-15 05:15:24 +00:00
CrazyMax
1edf6180e0 Merge pull request #179 from docker/dependabot/github_actions/codecov/codecov-action-3
Bump codecov/codecov-action from 2 to 3
2022-04-12 13:18:35 +02:00
dependabot[bot]
8e66ad4089 Bump codecov/codecov-action from 2 to 3
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-06 05:12:12 +00:00
CrazyMax
7c79b598ea Merge pull request #176 from docker/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-03-28 15:57:28 +02:00
dependabot[bot]
24a38e0d6d Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-27 13:30:24 +00:00
CrazyMax
70e1ff84cb Merge pull request #170 from crazy-max/eslint
dev: switch to eslint
2022-03-21 11:01:12 +01:00
CrazyMax
0828e0e718 dev: switch to eslint
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-21 10:58:19 +01:00
CrazyMax
56f72fcef0 dev: update bins and frontend
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-21 10:58:18 +01:00
CrazyMax
f169e16aaa Merge pull request #168 from docker/dependabot/npm_and_yarn/actions/io-1.1.2
Bump @actions/io from 1.1.1 to 1.1.2
2022-03-21 09:18:08 +01:00
dependabot[bot]
fa178e4710 Bump @actions/io from 1.1.1 to 1.1.2
Bumps [@actions/io](https://github.com/actions/toolkit/tree/HEAD/packages/io) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/io/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/io)

---
updated-dependencies:
- dependency-name: "@actions/io"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-21 08:15:07 +00:00
CrazyMax
a4bf4e934e Merge pull request #167 from docker/dependabot/npm_and_yarn/actions/exec-1.1.1
Bump @actions/exec from 1.1.0 to 1.1.1
2022-03-21 09:12:58 +01:00
dependabot[bot]
2bbd6e81e1 Bump @actions/exec from 1.1.0 to 1.1.1
Bumps [@actions/exec](https://github.com/actions/toolkit/tree/HEAD/packages/exec) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/exec/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/@actions/tool-cache@1.1.1/packages/exec)

---
updated-dependencies:
- dependency-name: "@actions/exec"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-18 05:14:07 +00:00
CrazyMax
f6d32ad023 Merge pull request #162 from docker/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-02 07:24:37 +01:00
dependabot[bot]
b4595c8bf9 Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 05:15:17 +00:00
19 changed files with 10263 additions and 32487 deletions

23
.eslintrc.json Normal file
View File

@@ -0,0 +1,23 @@
{
"env": {
"node": true,
"es2021": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest",
"prettier"
]
}

View File

@@ -15,7 +15,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Stop docker
run: |
@@ -39,7 +39,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitHub Container Registry
uses: ./
@@ -56,7 +56,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitHub Container Registry
uses: ./
@@ -81,7 +81,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to ACR
uses: ./
@@ -101,7 +101,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: ./
@@ -120,7 +120,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to ECR
uses: ./
@@ -140,7 +140,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
@@ -165,7 +165,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Public ECR
uses: ./
@@ -187,7 +187,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
@@ -212,7 +212,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitHub Container Registry
uses: ./
@@ -232,7 +232,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitLab
uses: ./
@@ -252,7 +252,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Google Artifact Registry
uses: ./
@@ -272,7 +272,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Google Container Registry
uses: ./

View File

@@ -16,7 +16,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Validate
uses: docker/bake-action@v1
@@ -29,6 +29,6 @@ jobs:
targets: test
-
name: Upload coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
file: ./coverage/clover.xml

View File

@@ -6,6 +6,7 @@ import * as exec from '@actions/exec';
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');
test('loginStandard calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
@@ -15,9 +16,9 @@ test('loginStandard calls exec', async () => {
};
});
const username: string = 'dbowie';
const password: string = 'groundcontrol';
const registry: string = 'https://ghcr.io';
const username = 'dbowie';
const password = 'groundcontrol';
const registry = 'https://ghcr.io';
await loginStandard(registry, username, password);
@@ -29,6 +30,7 @@ test('loginStandard calls exec', async () => {
});
test('logout calls exec', async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
@@ -38,7 +40,7 @@ test('logout calls exec', async () => {
};
});
const registry: string = 'https://ghcr.io';
const registry = 'https://ghcr.io';
await logout(registry);

View File

@@ -8,8 +8,7 @@ import * as stateHelper from '../src/state-helper';
import * as core from '@actions/core';
test('errors without username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy = jest.spyOn(core, 'setFailed');
@@ -18,21 +17,21 @@ test('errors without username and password', async () => {
});
test('successful with username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());
const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout: boolean = false;
const logout = false;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
@@ -43,25 +42,25 @@ test('successful with username and password', async () => {
});
test('calls docker login', async () => {
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(jest.fn());
const username: string = 'dbowie';
const username = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
const password: string = 'groundcontrol';
const password = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const registry: string = 'ghcr.io';
const registry = 'ghcr.io';
process.env[`INPUT_REGISTRY`] = registry;
const ecr: string = 'auto';
const ecr = 'auto';
process.env['INPUT_ECR'] = ecr;
const logout: boolean = true;
const logout = true;
process.env['INPUT_LOGOUT'] = String(logout);
await run();

View File

@@ -26,6 +26,6 @@ inputs:
required: false
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
post: 'dist/index.js'

View File

@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1.3-labs
# syntax=docker/dockerfile:1
ARG NODE_VERSION=12
ARG DOCKER_VERSION=20.10.10
ARG BUILDX_VERSION=0.7.0
ARG NODE_VERSION=16
ARG DOCKER_VERSION=20.10.13
ARG BUILDX_VERSION=0.8.1
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
@@ -57,10 +57,10 @@ RUN --mount=type=bind,target=.,rw \
FROM scratch AS format-update
COPY --from=format /out /
FROM deps AS format-validate
FROM deps AS lint
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run format-check
yarn run lint
FROM docker:${DOCKER_VERSION} as docker
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx

32412
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

1
dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

9468
dist/licenses.txt generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
dist/sourcemap-register.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@ group "pre-checkin" {
}
group "validate" {
targets = ["format-validate", "build-validate", "vendor-validate"]
targets = ["lint", "build-validate", "vendor-validate"]
}
target "build" {
@@ -28,9 +28,9 @@ target "format" {
output = ["."]
}
target "format-validate" {
target "lint" {
dockerfile = "dev.Dockerfile"
target = "format-validate"
target = "lint"
output = ["type=cacheonly"]
}

View File

@@ -6,5 +6,5 @@ module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: false
verbose: true
}

View File

@@ -3,11 +3,11 @@
"description": "GitHub Action to login against a Docker registry",
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
"test": "jest --coverage",
"pre-checkin": "yarn run format && yarn run build"
"all": "yarn run build && yarn run format && yarn test"
},
"repository": {
"type": "git",
@@ -28,20 +28,27 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.6.0",
"@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"@aws-sdk/client-ecr": "^3.53.0",
"@aws-sdk/client-ecr-public": "^3.53.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0"
"https-proxy-agent": "^5.0.1"
},
"devDependencies": {
"@types/node": "^16.11.26",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"@vercel/ncc": "^0.33.3",
"dotenv": "^16.0.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.5.1",
"prettier": "^2.3.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.7.0",
"typescript": "^4.4.4"
}
}

View File

@@ -34,7 +34,7 @@ export const getAccountIDs = (registry: string): string[] => {
if (!matches) {
return [];
}
let accountIDs: Array<string> = [matches[2]];
const accountIDs: Array<string> = [matches[2]];
if (process.env.AWS_ACCOUNT_IDS) {
accountIDs.push(...process.env.AWS_ACCOUNT_IDS.split(','));
}
@@ -57,14 +57,14 @@ export const getRegistriesData = async (registry: string, username?: string, pas
authTokenRequest['registryIds'] = accountIDs;
}
let httpProxyAgent: any = null;
let httpProxyAgent;
const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || '';
if (httpProxy) {
core.debug(`Using http proxy ${httpProxy}`);
httpProxyAgent = new HttpProxyAgent(httpProxy);
}
let httpsProxyAgent: any = null;
let httpsProxyAgent;
const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || '';
if (httpsProxy) {
core.debug(`Using https proxy ${httpsProxy}`);

View File

@@ -27,7 +27,7 @@ export async function loginStandard(registry: string, username: string, password
throw new Error('Username and password required');
}
let loginArgs: Array<string> = ['login', '--password-stdin'];
const loginArgs: Array<string> = ['login', '--password-stdin'];
loginArgs.push('--username', username);
loginArgs.push(registry);

View File

@@ -9,7 +9,7 @@ export async function run(): Promise<void> {
stateHelper.setRegistry(input.registry);
stateHelper.setLogout(input.logout);
await docker.login(input.registry, input.username, input.password, input.ecr);
} catch (error: any) {
} catch (error) {
core.setFailed(error.message);
}
}

View File

@@ -1,14 +1,19 @@
{
"compilerOptions": {
"target": "esnext",
"target": "es6",
"module": "commonjs",
"newLine": "lf",
"outDir": "./lib",
"rootDir": "./src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"sourceMap": true
"useUnknownInCatchVariables": false,
},
"exclude": ["node_modules", "**/*.test.ts"]
"exclude": [
"node_modules",
"**/*.test.ts",
"jest.config.ts"
]
}

712
yarn.lock

File diff suppressed because it is too large Load Diff