Compare commits

...

44 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
CrazyMax
dd4fa0671b Merge pull request #160 from crazy-max/node12
Revert to Node 12 as default runtime
2022-03-01 20:54:30 +01:00
CrazyMax
4e3538592e Revert to Node 12 as default runtime
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-01 20:51:18 +01:00
CrazyMax
bb984efc56 Merge pull request #156 from docker/dependabot/npm_and_yarn/aws-sdk/client-ecr-public-3.53.0
Bump @aws-sdk/client-ecr-public from 3.45.0 to 3.53.0
2022-02-28 09:04:17 +01:00
CrazyMax
722888132b Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-28 08:54:17 +01:00
dependabot[bot]
17780b56b7 Bump @aws-sdk/client-ecr-public from 3.45.0 to 3.53.0
Bumps [@aws-sdk/client-ecr-public](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-ecr-public) from 3.45.0 to 3.53.0.
- [Release notes](https://github.com/aws/aws-sdk-js-v3/releases)
- [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-ecr-public/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.53.0/clients/client-ecr-public)

---
updated-dependencies:
- dependency-name: "@aws-sdk/client-ecr-public"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-28 07:53:18 +00:00
CrazyMax
39857b3b45 Merge pull request #157 from docker/dependabot/npm_and_yarn/aws-sdk/client-ecr-3.53.0
Bump @aws-sdk/client-ecr from 3.45.0 to 3.53.0
2022-02-28 08:51:21 +01:00
CrazyMax
5fcc728422 Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-28 08:49:13 +01:00
dependabot[bot]
9fb8721eb9 Bump @aws-sdk/client-ecr from 3.45.0 to 3.53.0
Bumps [@aws-sdk/client-ecr](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-ecr) from 3.45.0 to 3.53.0.
- [Release notes](https://github.com/aws/aws-sdk-js-v3/releases)
- [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-ecr/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.53.0/clients/client-ecr)

---
updated-dependencies:
- dependency-name: "@aws-sdk/client-ecr"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-28 07:45:26 +00:00
CrazyMax
4e3c9375bb Merge pull request #158 from crazy-max/node-16
update to node 16
2022-02-28 08:43:40 +01:00
CrazyMax
4b59a429db update to node 16
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-28 08:29:00 +01:00
CrazyMax
6af3c118c8 Merge pull request #152 from crazy-max/aws-sdk-proxy
handle proxy settings for aws-sdk
2022-02-17 11:30:34 +01:00
CrazyMax
caca3368ce handle proxy settings for aws-sdk
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-16 13:53:16 +01:00
CrazyMax
17f28ab24d Merge pull request #112 from dineshba/workload-identity-gcr-gar
Update readme with workload identity based authentication for GCR and GAR
2022-02-03 17:48:36 +01:00
Dinesh B
a875dd0e21 Update readme with workload identity based authentication for GCR and GAR
Signed-off-by: Dinesh B <dineshudt17@gmail.com>
Signed-off-by: Dinesh <dineshb@thoughtworks.com>
2022-02-03 20:57:42 +05:30
CrazyMax
7948fffc49 Merge pull request #49 from crazy-max/e2e-acr
Test login against ACR
2022-01-27 13:07:02 +01:00
CrazyMax
5fcefb941d Merge pull request #131 from docker/dependabot/npm_and_yarn/aws-sdk/client-ecr-public-3.45.0
Bump @aws-sdk/client-ecr-public from 3.43.0 to 3.45.0
2021-12-30 20:49:49 +01:00
CrazyMax
3bb2d084df Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-12-30 20:43:44 +01:00
dependabot[bot]
242fb9a356 Bump @aws-sdk/client-ecr-public from 3.43.0 to 3.45.0
Bumps [@aws-sdk/client-ecr-public](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-ecr-public) from 3.43.0 to 3.45.0.
- [Release notes](https://github.com/aws/aws-sdk-js-v3/releases)
- [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-ecr-public/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.45.0/clients/client-ecr-public)

---
updated-dependencies:
- dependency-name: "@aws-sdk/client-ecr-public"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-30 19:41:46 +00:00
CrazyMax
fa72313bc3 Merge pull request #132 from docker/dependabot/npm_and_yarn/aws-sdk/client-ecr-3.45.0
Bump @aws-sdk/client-ecr from 3.44.0 to 3.45.0
2021-12-30 20:39:56 +01:00
CrazyMax
088f62a4f2 Update generated content
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-12-30 19:35:40 +01:00
dependabot[bot]
7929ac7647 Bump @aws-sdk/client-ecr from 3.44.0 to 3.45.0
Bumps [@aws-sdk/client-ecr](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-ecr) from 3.44.0 to 3.45.0.
- [Release notes](https://github.com/aws/aws-sdk-js-v3/releases)
- [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-ecr/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.45.0/clients/client-ecr)

---
updated-dependencies:
- dependency-name: "@aws-sdk/client-ecr"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-24 05:13:23 +00:00
CrazyMax
42d299face Merge pull request #130 from crazy-max/ci-workflow
Update ci workflow
2021-12-20 14:29:48 +01:00
CrazyMax
4858b0b5ea Update ci workflow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-12-20 14:27:18 +01:00
CrazyMax
1d7d8649e7 Merge pull request #128 from Flydiverny/aws-sdk-v3
fix(ecr): only set credentials if username & password if specified, refactor to use aws-sdk v3
2021-12-20 14:25:33 +01:00
Markus Maga
58855695bb refactor: use v3 sdk
Signed-off-by: Markus Maga <markus@maga.se>
2021-12-20 13:46:08 +01:00
CrazyMax
9376d24995 Test login against ACR
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2020-12-22 11:30:57 +01:00
21 changed files with 12060 additions and 44446 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: ./
@@ -76,6 +76,20 @@ jobs:
docker image prune -a -f >/dev/null 2>&1
docker pull ghcr.io/docker-ghactiontest/test
acr:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to ACR
uses: ./
with:
registry: ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io
username: ${{ secrets.AZURE_CLIENT_ID }}
password: ${{ secrets.AZURE_CLIENT_SECRET }}
dockerhub:
runs-on: ${{ matrix.os }}
strategy:
@@ -87,7 +101,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: ./
@@ -106,12 +120,12 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to ECR
uses: ./
with:
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -126,19 +140,19 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
aws-region: us-east-1
-
name: Login to ECR
uses: ./
with:
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com
ecr-public:
runs-on: ${{ matrix.os }}
@@ -151,7 +165,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Public ECR
uses: ./
@@ -159,6 +173,33 @@ jobs:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
ecr-public-aws-creds:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
-
name: Login to ECR
uses: ./
with:
registry: public.ecr.aws
github-container:
runs-on: ${{ matrix.os }}
@@ -171,7 +212,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitHub Container Registry
uses: ./
@@ -191,7 +232,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to GitLab
uses: ./
@@ -211,7 +252,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Login to Google Artifact Registry
uses: ./
@@ -231,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

104
README.md
View File

@@ -39,7 +39,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -64,7 +64,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -92,7 +92,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -118,7 +118,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -142,6 +142,45 @@ jobs:
> Google Container Registry, use the information [on this page](https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr)
> to learn about transitioning to Google Artifact Registry.
You can use either workload identity federation based keyless authentication or service account based authentication.
#### Workload identity federation based authentication
Configure the workload identity federation for github actions in gcloud (for steps, [refer here](https://github.com/google-github-actions/auth#setting-up-workload-identity-federation)). In the steps, your service account should the ability to push to GCR. Then use google-github-actions/auth action for authentication using workload identity like below:
```yaml
name: ci
on:
push:
branches: main
jobs:
login:
runs-on: ubuntu-latest
steps:
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '<workload_identity_provider>'
service_account: '<service_account>'
- name: Login to GCR
uses: docker/login-action@v1
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
```
> Replace `<workload_identity_provider>` with configured workload identity provider. For steps to configure, [refer here](https://github.com/google-github-actions/auth#setting-up-workload-identity-federation).
> Replace `<service_account>` with configured service account in workload identity provider which has access to push to GCR
#### Service account based authentication
Use a service account with the ability to push to GCR and [configure access control](https://cloud.google.com/container-registry/docs/access-control).
Then create and download the JSON key for this service account and save content of `.json` file
[as a secret](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository)
@@ -153,7 +192,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -170,6 +209,47 @@ jobs:
### Google Artifact Registry (GAR)
You can use either workload identity federation based keyless authentication or service account based authentication.
#### Workload identity federation based authentication
Configure the workload identity federation for github actions in gcloud (for steps, [refer here](https://github.com/google-github-actions/auth#setting-up-workload-identity-federation)). In the steps, your service account should the ability to push to GAR. Then use google-github-actions/auth action for authentication using workload identity like below:
```yaml
name: ci
on:
push:
branches: main
jobs:
login:
runs-on: ubuntu-latest
steps:
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '<workload_identity_provider>'
service_account: '<service_account>'
- name: Login to GAR
uses: docker/login-action@v1
with:
registry: <location>-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
```
> Replace `<workload_identity_provider>` with configured workload identity provider
> Replace `<service_account>` with configured service account in workload identity provider which has access to push to GCR
> Replace `<location>` with the regional or multi-regional [location](https://cloud.google.com/artifact-registry/docs/repo-organize#locations)
> of the repository where the image is stored.
#### Service account based authentication
Use a service account with the ability to push to GAR and [configure access control](https://cloud.google.com/artifact-registry/docs/access-control).
Then create and download the JSON key for this service account and save content of `.json` file
[as a secret](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository)
@@ -181,7 +261,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -210,7 +290,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -233,7 +313,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -260,7 +340,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -293,7 +373,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -327,7 +407,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:
@@ -353,7 +433,7 @@ name: ci
on:
push:
branches: master
branches: main
jobs:
login:

View File

@@ -1,5 +1,6 @@
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import {AuthorizationData} from '@aws-sdk/client-ecr';
import * as aws from '../src/aws';
import {AuthorizationData} from 'aws-sdk/clients/ecr';
describe('isECR', () => {
test.each([
@@ -55,11 +56,15 @@ describe('getAccountIDs', () => {
const mockEcrGetAuthToken = jest.fn();
const mockEcrPublicGetAuthToken = jest.fn();
jest.mock('aws-sdk', () => {
jest.mock('@aws-sdk/client-ecr', () => {
return {
ECR: jest.fn(() => ({
getAuthorizationToken: mockEcrGetAuthToken
})),
}))
};
});
jest.mock('@aws-sdk/client-ecr-public', () => {
return {
ECRPUBLIC: jest.fn(() => ({
getAuthorizationToken: mockEcrPublicGetAuthToken
}))
@@ -126,15 +131,11 @@ describe('getRegistriesData', () => {
const authData: AuthorizationData[] = [];
if (accountIDs.length == 0) {
mockEcrPublicGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
});
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
};
});
});
} else {
aws.getAccountIDs(registry).forEach(accountID => {
@@ -144,13 +145,9 @@ describe('getRegistriesData', () => {
});
});
mockEcrGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: authData
});
}
};
return Promise.resolve({
authorizationData: authData
});
});
}
const regData = await aws.getRegistriesData(registry);

View File

@@ -1,3 +1,4 @@
import {expect, test} from '@jest/globals';
import {getInputs} from '../src/context';
test('with password and username getInputs does not throw error', async () => {

View File

@@ -1,24 +1,24 @@
import {expect, jest, test} from '@jest/globals';
import {loginStandard, logout} from '../src/docker';
import * as path from 'path';
import * as exec from '@actions/exec';
process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');
test('loginStandard calls exec', async () => {
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
execSpy.mockImplementation(() =>
Promise.resolve({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
stderr: expect.any(Function)
})
);
};
});
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);
@@ -30,16 +30,17 @@ test('loginStandard calls exec', async () => {
});
test('logout calls exec', async () => {
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
execSpy.mockImplementation(() =>
Promise.resolve({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
stderr: expect.any(Function)
})
);
};
});
const registry: string = 'https://ghcr.io';
const registry = 'https://ghcr.io';
await logout(registry);

View File

@@ -1,3 +1,4 @@
import {expect, jest, test} from '@jest/globals';
import osm = require('os');
import {run} from '../src/main';
@@ -7,37 +8,30 @@ 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');
platSpy.mockImplementation(() => 'linux');
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy: jest.SpyInstance = jest.spyOn(core, 'setFailed');
const coreSpy = jest.spyOn(core, 'setFailed');
await run();
expect(coreSpy).toHaveBeenCalledWith('Username and password required');
});
test('successful with username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.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 setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});
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();
@@ -48,27 +42,25 @@ test('successful with username and password', async () => {
});
test('calls docker login', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.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 setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});
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
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

42602
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

@@ -1,13 +1,3 @@
variable "NODE_VERSION" {
default = "12"
}
target "node-version" {
args = {
NODE_VERSION = NODE_VERSION
}
}
group "default" {
targets = ["build"]
}
@@ -17,54 +7,47 @@ group "pre-checkin" {
}
group "validate" {
targets = ["format-validate", "build-validate", "vendor-validate"]
targets = ["lint", "build-validate", "vendor-validate"]
}
target "build" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "build-update"
output = ["."]
}
target "build-validate" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "build-validate"
output = ["type=cacheonly"]
}
target "format" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "format-update"
output = ["."]
}
target "format-validate" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
target = "format-validate"
target "lint" {
dockerfile = "dev.Dockerfile"
target = "lint"
output = ["type=cacheonly"]
}
target "vendor-update" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "vendor-update"
output = ["."]
}
target "vendor-validate" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "vendor-validate"
output = ["type=cacheonly"]
}
target "test" {
inherits = ["node-version"]
dockerfile = "./hack/build.Dockerfile"
dockerfile = "dev.Dockerfile"
target = "test-coverage"
output = ["./coverage"]
}

View File

@@ -2,11 +2,9 @@ module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
setupFiles: ["dotenv/config"],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
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,21 +28,27 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.6.0",
"@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1",
"aws-sdk": "^2.1046.0"
"@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.1"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^14.17.4",
"@vercel/ncc": "^0.28.6",
"dotenv": "^8.6.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-runtime": "^26.6.3",
"prettier": "^2.3.2",
"ts-jest": "^26.5.6",
"typescript": "^3.9.10",
"typescript-formatter": "^7.2.2"
"@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.3.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.7.0",
"typescript": "^4.4.4"
}
}

View File

@@ -1,5 +1,9 @@
import * as core from '@actions/core';
import * as aws from 'aws-sdk';
import {ECR} from '@aws-sdk/client-ecr';
import {ECRPUBLIC} from '@aws-sdk/client-ecr-public';
import {NodeHttpHandler} from '@aws-sdk/node-http-handler';
import {HttpProxyAgent} from 'http-proxy-agent';
import {HttpsProxyAgent} from 'https-proxy-agent';
const ecrRegistryRegex = /^(([0-9]{12})\.dkr\.ecr\.(.+)\.amazonaws\.com(.cn)?)(\/([^:]+)(:.+)?)?$/;
@@ -30,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(','));
}
@@ -53,15 +57,40 @@ export const getRegistriesData = async (registry: string, username?: string, pas
authTokenRequest['registryIds'] = accountIDs;
}
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;
const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || '';
if (httpsProxy) {
core.debug(`Using https proxy ${httpsProxy}`);
httpsProxyAgent = new HttpsProxyAgent(httpsProxy);
}
const credentials =
username && password
? {
accessKeyId: username,
secretAccessKey: password
}
: undefined;
if (isPubECR(registry)) {
core.info(`AWS Public ECR detected with ${region} region`);
const ecrPublic = new aws.ECRPUBLIC({
const ecrPublic = new ECRPUBLIC({
customUserAgent: 'docker-login-action',
accessKeyId: username || process.env.AWS_ACCESS_KEY_ID || '',
secretAccessKey: password || process.env.AWS_SECRET_ACCESS_KEY || '',
region: region
credentials,
region: region,
requestHandler: new NodeHttpHandler({
httpAgent: httpProxyAgent,
httpsAgent: httpsProxyAgent
})
});
const authTokenResponse = await ecrPublic.getAuthorizationToken(authTokenRequest).promise();
const authTokenResponse = await ecrPublic.getAuthorizationToken(authTokenRequest);
if (!authTokenResponse.authorizationData || !authTokenResponse.authorizationData.authorizationToken) {
throw new Error('Could not retrieve an authorization token from AWS Public ECR');
}
@@ -76,13 +105,16 @@ export const getRegistriesData = async (registry: string, username?: string, pas
];
} else {
core.info(`AWS ECR detected with ${region} region`);
const ecr = new aws.ECR({
const ecr = new ECR({
customUserAgent: 'docker-login-action',
accessKeyId: username || process.env.AWS_ACCESS_KEY_ID || '',
secretAccessKey: password || process.env.AWS_SECRET_ACCESS_KEY || '',
region: region
credentials,
region: region,
requestHandler: new NodeHttpHandler({
httpAgent: httpProxyAgent,
httpsAgent: httpsProxyAgent
})
});
const authTokenResponse = await ecr.getAuthorizationToken(authTokenRequest).promise();
const authTokenResponse = await ecr.getAuthorizationToken(authTokenRequest);
if (!Array.isArray(authTokenResponse.authorizationData) || !authTokenResponse.authorizationData.length) {
throw new Error('Could not retrieve an authorization token from AWS ECR');
}

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

@@ -2,17 +2,18 @@
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"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"
]
}

3947
yarn.lock

File diff suppressed because it is too large Load Diff