mirror of
https://github.com/docker/login-action.git
synced 2026-07-22 20:57:57 +00:00
Compare commits
146 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e3d36ea10 | |||
| 14d6a7934e | |||
| 03c851098f | |||
| ad8a81f098 | |||
| 6d219a4928 | |||
| b3200694f4 | |||
| 08d3680aa8 | |||
| 381f5a4f5e | |||
| 4bc69ce4fd | |||
| ddf94996dc | |||
| d870eb57d3 | |||
| 4d7b1348c8 | |||
| 608836776e | |||
| 3bab31f360 | |||
| dc654b7be1 | |||
| c66a8fcb24 | |||
| 6d7f9d458a | |||
| 13169716da | |||
| c1aa9e5f45 | |||
| 026f3975fd | |||
| 3dbb99fd00 | |||
| af1e73f918 | |||
| da722bde43 | |||
| 2916ad60bd | |||
| ca0a662f78 | |||
| c455755a57 | |||
| 48351901f8 | |||
| 992421c6e6 | |||
| b249b43765 | |||
| 1b67977736 | |||
| 9d49d6a323 | |||
| c99871dec2 | |||
| b43355553d | |||
| 678a46a45e | |||
| f9a0aea0f2 | |||
| cc1e4cb459 | |||
| 02e1730369 | |||
| b548518374 | |||
| a244be3944 | |||
| ee0d698156 | |||
| 127dc2c62e | |||
| 28d93c8e86 | |||
| bb4abc2b4e | |||
| 46b0f7f7db | |||
| 02ce84ffb2 | |||
| aac44b8023 | |||
| e6a67367bb | |||
| e12cbe383a | |||
| 9ef03105cf | |||
| cca864db18 | |||
| ecd3da5c9a | |||
| 9f1db17ebe | |||
| c52380340b | |||
| f941705c01 | |||
| 1a44f13eda | |||
| 4691d54c76 | |||
| 2564fa2273 | |||
| 1d117b3de6 | |||
| 54354cec26 | |||
| 291ce15746 | |||
| d144cc9aaf | |||
| 9bc29939f1 | |||
| 42702f7ab5 | |||
| c5a66b573f | |||
| f356dc0f57 | |||
| 82c046b85a | |||
| f482210217 | |||
| 528895cbd3 | |||
| 3be61c42c8 | |||
| 3d128cd17b | |||
| 4755f4fe4d | |||
| 17f7c1809f | |||
| a2447fe0f6 | |||
| 3864d6aed8 | |||
| 64b25388de | |||
| 17162ab65f | |||
| 37a9a4b333 | |||
| eb1946f59c | |||
| 946f94de75 | |||
| c07548e8a6 | |||
| 20036e466f | |||
| f50e5f80f8 | |||
| c5e5fd0017 | |||
| 60e5331f1c | |||
| 6a848e5a16 | |||
| 0267638d8a | |||
| 250c56f969 | |||
| 3999a1f436 | |||
| 0c083d7a7a | |||
| d74126fafb | |||
| 008abcd773 | |||
| b3d0cb50ae | |||
| d1f19df6c2 | |||
| f9a14677ff | |||
| 72b845d964 | |||
| 22319e3a05 | |||
| 9ff664c6c9 | |||
| 394f625bb6 | |||
| 42471eb9ff | |||
| 04bf81902c | |||
| 5dbe09f08d | |||
| 652059025f | |||
| 2ff7bc63ff | |||
| 8f60ab8910 | |||
| 401fdfb10a | |||
| 9720944471 | |||
| b04cd7ece0 | |||
| 650006c6eb | |||
| 99df1a3f6d | |||
| 3ab375f324 | |||
| 39d85804ae | |||
| 4eefcd33ca | |||
| 56d092c8b3 | |||
| e2e31ca870 | |||
| 0bced941e8 | |||
| 3e75a0f266 | |||
| 365bebd9d6 | |||
| e7f6f8a91a | |||
| 05480f2a7d | |||
| 31f21c3443 | |||
| 4f5a161ff1 | |||
| e15d361870 | |||
| 9baec518af | |||
| 66b5047e43 | |||
| dae8e21ce2 | |||
| 0045eaa7a1 | |||
| 450ca8c2a5 | |||
| d6726b3526 | |||
| a2ea2dd0f1 | |||
| bd659cc69e | |||
| 43261b75b0 | |||
| 745e12c13f | |||
| 5244cbf81d | |||
| 6778676cba | |||
| 24be3e65e6 | |||
| 9abe73fe0b | |||
| b45b323e05 | |||
| 963c6a6d1b | |||
| 2254f031f7 | |||
| d85f62f7d4 | |||
| 604e8e9cf4 | |||
| 482acf1aaf | |||
| 9f4a8ea54e | |||
| 6831c7566c | |||
| 599ec30da7 | |||
| 174f89633e |
@@ -10,6 +10,9 @@ updates:
|
|||||||
crazy-max-dot-github:
|
crazy-max-dot-github:
|
||||||
patterns:
|
patterns:
|
||||||
- "crazy-max/.github/*"
|
- "crazy-max/.github/*"
|
||||||
|
codeql-actions:
|
||||||
|
patterns:
|
||||||
|
- "github/codeql-action/*"
|
||||||
labels:
|
labels:
|
||||||
- "dependencies"
|
- "dependencies"
|
||||||
- "bot"
|
- "bot"
|
||||||
|
|||||||
+156
-44
@@ -7,6 +7,9 @@ concurrency:
|
|||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
GHCR_TEST_IMAGE: ghcr.io/docker/login-action-test:ci-${{ github.sha }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -22,7 +25,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
@@ -46,7 +49,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitHub Container Registry
|
name: Login to GitHub Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -56,44 +59,75 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
logout: ${{ matrix.logout }}
|
logout: ${{ matrix.logout }}
|
||||||
|
|
||||||
dind:
|
push-ghcr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
permissions:
|
||||||
DOCKER_CONFIG: $HOME/.docker
|
contents: read
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitHub Container Registry
|
name: Login to GitHub Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ secrets.GHCR_USERNAME }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GHCR_PAT }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push test image
|
||||||
|
run: |
|
||||||
|
docker buildx build --push -t "${GHCR_TEST_IMAGE}" - <<EOF
|
||||||
|
FROM scratch
|
||||||
|
LABEL org.opencontainers.image.title="docker/login-action CI test image"
|
||||||
|
LABEL org.opencontainers.image.description="Empty image used by CI to verify GHCR authentication."
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
dind:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- push-ghcr
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: read
|
||||||
|
env:
|
||||||
|
DOCKER_CONFIG: $HOME/.docker
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
-
|
||||||
|
name: Login to GitHub Container Registry
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: DinD
|
name: DinD
|
||||||
uses: docker://docker:29.3@sha256:4d90f1f6c400315c2dba96d3ec93c01e64198395cbba04f79d12adce4f737029
|
uses: docker://docker:29.3@sha256:4d90f1f6c400315c2dba96d3ec93c01e64198395cbba04f79d12adce4f737029
|
||||||
with:
|
with:
|
||||||
entrypoint: docker
|
entrypoint: docker
|
||||||
args: pull ghcr.io/docker-ghactiontest/test
|
args: pull ${{ env.GHCR_TEST_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Pull private image
|
name: Pull test image
|
||||||
run: |
|
run: |
|
||||||
docker image prune -a -f >/dev/null 2>&1
|
docker image prune -a -f >/dev/null 2>&1
|
||||||
docker pull ghcr.io/docker-ghactiontest/test
|
docker pull "${GHCR_TEST_IMAGE}"
|
||||||
|
|
||||||
acr:
|
acr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to ACR
|
name: Login to ACR
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io
|
registry: officialgithubactions.azurecr.io
|
||||||
username: ${{ secrets.AZURE_CLIENT_ID }}
|
username: ${{ secrets.AZURE_CLIENT_ID }}
|
||||||
password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
||||||
|
|
||||||
@@ -108,13 +142,36 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ vars.DOCKERPUBLICBOT_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERPUBLICBOT_READ_PAT }}
|
||||||
|
|
||||||
|
dockerhub-oidc:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub with OIDC
|
||||||
|
uses: ./
|
||||||
|
env:
|
||||||
|
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_OIDC_USERNAME }}
|
||||||
|
|
||||||
ecr:
|
ecr:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -127,12 +184,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to ECR
|
name: Login to ECR
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com
|
registry: 175142243308.dkr.ecr.us-east-1.amazonaws.com
|
||||||
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
|
||||||
@@ -147,10 +204,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Configure AWS Credentials
|
name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
|
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||||
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 }}
|
||||||
@@ -159,7 +216,34 @@ jobs:
|
|||||||
name: Login to ECR
|
name: Login to ECR
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com
|
registry: 175142243308.dkr.ecr.us-east-1.amazonaws.com
|
||||||
|
|
||||||
|
ecr-oidc:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
-
|
||||||
|
name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||||
|
with:
|
||||||
|
role-to-assume: arn:aws:iam::175142243308:role/official_gha_cicd_login_action
|
||||||
|
aws-region: us-east-1
|
||||||
|
-
|
||||||
|
name: Login to ECR
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
registry: 175142243308.dkr.ecr.us-east-1.amazonaws.com
|
||||||
|
|
||||||
ecr-public:
|
ecr-public:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -172,7 +256,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Public ECR
|
name: Login to Public ECR
|
||||||
continue-on-error: ${{ matrix.os == 'windows-latest' }}
|
continue-on-error: ${{ matrix.os == 'windows-latest' }}
|
||||||
@@ -195,10 +279,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Configure AWS Credentials
|
name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
|
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||||
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 }}
|
||||||
@@ -210,6 +294,34 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
registry: public.ecr.aws
|
registry: public.ecr.aws
|
||||||
|
|
||||||
|
ecr-public-oidc:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
-
|
||||||
|
name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
|
||||||
|
with:
|
||||||
|
role-to-assume: arn:aws:iam::175142243308:role/official_gha_cicd_login_action
|
||||||
|
aws-region: us-east-1
|
||||||
|
-
|
||||||
|
name: Login to Public ECR
|
||||||
|
continue-on-error: ${{ matrix.os == 'windows-latest' }}
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
registry: public.ecr.aws
|
||||||
|
|
||||||
ghcr:
|
ghcr:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -221,7 +333,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitHub Container Registry
|
name: Login to GitHub Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -241,7 +353,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitLab
|
name: Login to GitLab
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -261,12 +373,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Google Artifact Registry
|
name: Login to Google Artifact Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.GAR_LOCATION }}-docker.pkg.dev
|
registry: us-east4-docker.pkg.dev
|
||||||
username: _json_key
|
username: _json_key
|
||||||
password: ${{ secrets.GAR_JSON_KEY }}
|
password: ${{ secrets.GAR_JSON_KEY }}
|
||||||
|
|
||||||
@@ -281,7 +393,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Google Container Registry
|
name: Login to Google Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -295,14 +407,14 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to registries
|
name: Login to registries
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
registry-auth: |
|
registry-auth: |
|
||||||
- username: ${{ secrets.DOCKERHUB_USERNAME }}
|
- username: ${{ vars.DOCKERPUBLICBOT_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERPUBLICBOT_READ_PAT }}
|
||||||
- registry: ghcr.io
|
- registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -318,7 +430,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to registries
|
name: Login to registries
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -339,7 +451,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to registries
|
name: Login to registries
|
||||||
id: login
|
id: login
|
||||||
@@ -350,8 +462,8 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
registry-auth: |
|
registry-auth: |
|
||||||
- username: ${{ secrets.DOCKERHUB_USERNAME }}
|
- username: ${{ vars.DOCKERPUBLICBOT_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERPUBLICBOT_READ_PAT }}
|
||||||
-
|
-
|
||||||
name: Check
|
name: Check
|
||||||
run: |
|
run: |
|
||||||
@@ -371,13 +483,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ vars.DOCKERPUBLICBOT_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERPUBLICBOT_READ_PAT }}
|
||||||
scope: '@push'
|
scope: '@push'
|
||||||
-
|
-
|
||||||
name: Print config.json files
|
name: Print config.json files
|
||||||
@@ -401,13 +513,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ vars.DOCKERPUBLICBOT_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERPUBLICBOT_READ_PAT }}
|
||||||
scope: 'docker/buildx-bin@push'
|
scope: 'docker/buildx-bin@push'
|
||||||
-
|
-
|
||||||
name: Print config.json files
|
name: Print config.json files
|
||||||
@@ -431,7 +543,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitHub Container Registry
|
name: Login to GitHub Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -462,7 +574,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Login to GitHub Container Registry
|
name: Login to GitHub Container Registry
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Enable corepack
|
name: Enable corepack
|
||||||
run: |
|
run: |
|
||||||
@@ -30,17 +30,17 @@ jobs:
|
|||||||
yarn --version
|
yarn --version
|
||||||
-
|
-
|
||||||
name: Set up Node
|
name: Set up Node
|
||||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
-
|
-
|
||||||
name: Initialize CodeQL
|
name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
|
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||||
with:
|
with:
|
||||||
languages: javascript-typescript
|
languages: javascript-typescript
|
||||||
build-mode: none
|
build-mode: none
|
||||||
-
|
-
|
||||||
name: Perform CodeQL Analysis
|
name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
|
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||||
with:
|
with:
|
||||||
category: "/language:javascript-typescript"
|
category: "/language:javascript-typescript"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@4a17dbaa9ce13920fc5bb8824eb89c16301e5ab2 # v1.7.0
|
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@46267a6e61cd56aac2fc79943df180152f4c89d6 # v1.10.1
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Publish
|
name: Publish
|
||||||
uses: actions/publish-immutable-action@4bc8754ffc40f27910afb20287dbbbb675a4e978 # v0.0.4
|
uses: actions/publish-immutable-action@4bc8754ffc40f27910afb20287dbbbb675a4e978 # v0.0.4
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
||||||
with:
|
with:
|
||||||
source: .
|
source: .
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
||||||
with:
|
with:
|
||||||
files: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
@@ -21,21 +21,23 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: GitHub auth token from GitHub App
|
name: GitHub auth token from GitHub App
|
||||||
id: docker-read-app
|
id: docker-read-app
|
||||||
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
|
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||||
with:
|
with:
|
||||||
app-id: ${{ secrets.GHACTIONS_REPO_WRITE_APP_ID }}
|
app-id: ${{ secrets.GHACTIONS_REPO_WRITE_APP_ID }}
|
||||||
private-key: ${{ secrets.GHACTIONS_REPO_WRITE_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.GHACTIONS_REPO_WRITE_APP_PRIVATE_KEY }}
|
||||||
owner: docker
|
owner: docker
|
||||||
|
repositories: login-action
|
||||||
|
permission-contents: write
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ steps.docker-read-app.outputs.token }}
|
token: ${{ steps.docker-read-app.outputs.token }}
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
||||||
with:
|
with:
|
||||||
source: .
|
source: .
|
||||||
targets: build
|
targets: build
|
||||||
@@ -48,7 +50,7 @@ jobs:
|
|||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
git add dist
|
git add dist
|
||||||
git commit -m "chore: update generated content"
|
git commit -m "[dependabot skip] chore: update generated content"
|
||||||
git push
|
git push
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
-
|
-
|
||||||
name: Generate matrix
|
name: Generate matrix
|
||||||
id: generate
|
id: generate
|
||||||
uses: docker/bake-action/subaction/matrix@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action/subaction/matrix@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
||||||
with:
|
with:
|
||||||
target: validate
|
target: validate
|
||||||
|
|
||||||
@@ -41,6 +41,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
zizmor:
|
zizmor:
|
||||||
uses: crazy-max/.github/.github/workflows/zizmor.yml@4a17dbaa9ce13920fc5bb8824eb89c16301e5ab2 # v1.7.0
|
uses: crazy-max/.github/.github/workflows/zizmor.yml@46267a6e61cd56aac2fc79943df180152f4c89d6 # v1.10.1
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
security-events: write
|
security-events: write
|
||||||
|
|||||||
+11
-4
@@ -1,10 +1,10 @@
|
|||||||
# https://yarnpkg.com/configuration/yarnrc
|
# https://yarnpkg.com/configuration/yarnrc
|
||||||
|
|
||||||
compressionLevel: mixed
|
nodeLinker: node-modules
|
||||||
enableGlobalCache: false
|
|
||||||
enableHardenedMode: true
|
|
||||||
|
|
||||||
logFilters:
|
logFilters:
|
||||||
|
- code: YN0004
|
||||||
|
level: discard
|
||||||
- code: YN0013
|
- code: YN0013
|
||||||
level: discard
|
level: discard
|
||||||
- code: YN0019
|
- code: YN0019
|
||||||
@@ -14,4 +14,11 @@ logFilters:
|
|||||||
- code: YN0086
|
- code: YN0086
|
||||||
level: discard
|
level: discard
|
||||||
|
|
||||||
nodeLinker: node-modules
|
npmPreapprovedPackages:
|
||||||
|
- "@docker/actions-toolkit"
|
||||||
|
|
||||||
|
compressionLevel: mixed
|
||||||
|
enableGlobalCache: false
|
||||||
|
enableHardenedMode: true
|
||||||
|
enableScripts: false
|
||||||
|
npmMinimalAgeGate: 2d
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ ___
|
|||||||
* [Set scopes for the authentication token](#set-scopes-for-the-authentication-token)
|
* [Set scopes for the authentication token](#set-scopes-for-the-authentication-token)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
|
* [environment variables](#environment-variables)
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -57,6 +58,36 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also [authenticate to Docker Hub with OpenID Connect](https://docs.docker.com/enterprise/security/oidc-connections/)
|
||||||
|
when your Docker Hub organization has an OIDC connection configured. The
|
||||||
|
workflow must grant the `id-token: write` permission, pass the Docker Hub
|
||||||
|
organization name as `username`, omit `password`, and set the OIDC connection
|
||||||
|
ID in `DOCKERHUB_OIDC_CONNECTIONID` environment variable.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
login:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
env:
|
||||||
|
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_ORGANIZATION }}
|
||||||
|
```
|
||||||
|
|
||||||
### GitHub Container Registry
|
### GitHub Container Registry
|
||||||
|
|
||||||
To authenticate to the [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry),
|
To authenticate to the [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry),
|
||||||
@@ -117,6 +148,8 @@ instead of a password.
|
|||||||
|
|
||||||
### Azure Container Registry (ACR)
|
### Azure Container Registry (ACR)
|
||||||
|
|
||||||
|
#### Service principal
|
||||||
|
|
||||||
[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)
|
||||||
with access to your container registry through the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
|
with access to your container registry through the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
|
||||||
and take note of the generated service principal's ID (also called _client ID_)
|
and take note of the generated service principal's ID (also called _client ID_)
|
||||||
@@ -142,10 +175,60 @@ jobs:
|
|||||||
password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Replace `<registry-name>` with the name of your registry.
|
||||||
|
|
||||||
|
#### OpenID Connect (OIDC)
|
||||||
|
|
||||||
|
To authenticate with OpenID Connect, configure a federated identity credential
|
||||||
|
for GitHub Actions and use the [Azure Login](https://github.com/Azure/login)
|
||||||
|
action to sign in to Azure. Then expose an ACR access token and pass it to this
|
||||||
|
action as the password.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
login:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Login to Azure
|
||||||
|
uses: azure/login@v3
|
||||||
|
with:
|
||||||
|
client-id: ${{ vars.AZURE_CLIENT_ID }}
|
||||||
|
tenant-id: ${{ vars.AZURE_TENANT_ID }}
|
||||||
|
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
|
||||||
|
-
|
||||||
|
name: Get ACR access token
|
||||||
|
id: acr-token
|
||||||
|
run: |
|
||||||
|
ACR_TOKEN=$(az acr login --name <registry-name> --expose-token --output tsv --query accessToken)
|
||||||
|
echo "::add-mask::$ACR_TOKEN" # mask the token in workflow logs
|
||||||
|
echo "token=$ACR_TOKEN" >> "$GITHUB_OUTPUT"
|
||||||
|
-
|
||||||
|
name: Login to ACR
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
registry: <registry-name>.azurecr.io
|
||||||
|
username: 00000000-0000-0000-0000-000000000000
|
||||||
|
password: ${{ steps.acr-token.outputs.token }}
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<registry-name>` with the name of your registry.
|
> Replace `<registry-name>` with the name of your registry.
|
||||||
|
|
||||||
### Google Container Registry (GCR)
|
### Google Container Registry (GCR)
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> [Google Artifact Registry](#google-artifact-registry-gar) is the evolution of
|
> [Google Artifact Registry](#google-artifact-registry-gar) is the evolution of
|
||||||
> Google Container Registry. As a fully-managed service with support for both
|
> Google Container Registry. As a fully-managed service with support for both
|
||||||
> container images and non-container artifacts. If you currently use Google
|
> container images and non-container artifacts. If you currently use Google
|
||||||
@@ -176,7 +259,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Authenticate to Google Cloud
|
name: Authenticate to Google Cloud
|
||||||
id: auth
|
id: auth
|
||||||
uses: google-github-actions/auth@v1
|
uses: google-github-actions/auth@v3
|
||||||
with:
|
with:
|
||||||
token_format: access_token
|
token_format: access_token
|
||||||
workload_identity_provider: <workload_identity_provider>
|
workload_identity_provider: <workload_identity_provider>
|
||||||
@@ -190,9 +273,10 @@ jobs:
|
|||||||
password: ${{ steps.auth.outputs.access_token }}
|
password: ${{ steps.auth.outputs.access_token }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<workload_identity_provider>` with configured workload identity
|
> Replace `<workload_identity_provider>` with configured workload identity
|
||||||
> provider. For steps to configure, [see here](https://github.com/google-github-actions/auth#setting-up-workload-identity-federation).
|
> provider. For steps to configure, [see here](https://github.com/google-github-actions/auth#setting-up-workload-identity-federation).
|
||||||
|
>
|
||||||
> Replace `<service_account>` with configured service account in workload
|
> Replace `<service_account>` with configured service account in workload
|
||||||
> identity provider which has access to push to GCR
|
> identity provider which has access to push to GCR
|
||||||
|
|
||||||
@@ -247,7 +331,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Authenticate to Google Cloud
|
name: Authenticate to Google Cloud
|
||||||
id: auth
|
id: auth
|
||||||
uses: google-github-actions/auth@v1
|
uses: google-github-actions/auth@v3
|
||||||
with:
|
with:
|
||||||
token_format: access_token
|
token_format: access_token
|
||||||
workload_identity_provider: <workload_identity_provider>
|
workload_identity_provider: <workload_identity_provider>
|
||||||
@@ -261,12 +345,13 @@ jobs:
|
|||||||
password: ${{ steps.auth.outputs.access_token }}
|
password: ${{ steps.auth.outputs.access_token }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<workload_identity_provider>` with configured workload identity
|
> Replace `<workload_identity_provider>` with configured workload identity
|
||||||
> provider
|
> provider
|
||||||
|
>
|
||||||
> Replace `<service_account>` with configured service account in workload
|
> Replace `<service_account>` with configured service account in workload
|
||||||
> identity provider which has access to push to GCR
|
> 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)
|
> 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.
|
> of the repository where the image is stored.
|
||||||
|
|
||||||
@@ -298,6 +383,7 @@ jobs:
|
|||||||
password: ${{ secrets.GAR_JSON_KEY }}
|
password: ${{ secrets.GAR_JSON_KEY }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<location>` with the regional or multi-regional [location](https://cloud.google.com/artifact-registry/docs/repo-organize#locations)
|
> 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.
|
> of the repository where the image is stored.
|
||||||
|
|
||||||
@@ -352,6 +438,7 @@ jobs:
|
|||||||
AWS_ACCOUNT_IDS: 012345678910,023456789012
|
AWS_ACCOUNT_IDS: 012345678910,023456789012
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Only available with [AWS CLI version 1](https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html)
|
> Only available with [AWS CLI version 1](https://docs.aws.amazon.com/cli/latest/reference/ecr/get-login.html)
|
||||||
|
|
||||||
You can also use the [Configure AWS Credentials](https://github.com/aws-actions/configure-aws-credentials)
|
You can also use the [Configure AWS Credentials](https://github.com/aws-actions/configure-aws-credentials)
|
||||||
@@ -370,7 +457,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Configure AWS Credentials
|
name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: aws-actions/configure-aws-credentials@v6
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
@@ -382,6 +469,7 @@ jobs:
|
|||||||
registry: <aws-account-number>.dkr.ecr.<region>.amazonaws.com
|
registry: <aws-account-number>.dkr.ecr.<region>.amazonaws.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<aws-account-number>` and `<region>` with their respective values.
|
> Replace `<aws-account-number>` and `<region>` with their respective values.
|
||||||
|
|
||||||
### AWS Public Elastic Container Registry (ECR)
|
### AWS Public Elastic Container Registry (ECR)
|
||||||
@@ -413,6 +501,7 @@ jobs:
|
|||||||
AWS_REGION: <region>
|
AWS_REGION: <region>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<region>` with its respective value (default `us-east-1`).
|
> Replace `<region>` with its respective value (default `us-east-1`).
|
||||||
|
|
||||||
### OCI Oracle Cloud Infrastructure Registry (OCIR)
|
### OCI Oracle Cloud Infrastructure Registry (OCIR)
|
||||||
@@ -445,6 +534,7 @@ jobs:
|
|||||||
password: ${{ secrets.OCI_TOKEN }}
|
password: ${{ secrets.OCI_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> Replace `<region>` with their respective values from [availability regions](https://docs.cloud.oracle.com/iaas/Content/Registry/Concepts/registryprerequisites.htm#Availab)
|
> Replace `<region>` with their respective values from [availability regions](https://docs.cloud.oracle.com/iaas/Content/Registry/Concepts/registryprerequisites.htm#Availab)
|
||||||
|
|
||||||
### Quay.io
|
### Quay.io
|
||||||
@@ -603,7 +693,7 @@ jobs:
|
|||||||
scope: 'myorg/myimage@push'
|
scope: 'myorg/myimage@push'
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: myorg/myimage:latest
|
tags: myorg/myimage:latest
|
||||||
@@ -631,6 +721,15 @@ The following inputs can be used as `step.with` keys:
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> The `registry-auth` input cannot be used with other inputs except `logout`.
|
> The `registry-auth` input cannot be used with other inputs except `logout`.
|
||||||
|
|
||||||
|
### environment variables
|
||||||
|
|
||||||
|
The following environment variables can be set as `step.env` keys:
|
||||||
|
|
||||||
|
| Name | Type | Default | Description |
|
||||||
|
|-------------------------------|--------|---------|-----------------------------------------------------------------------------|
|
||||||
|
| `DOCKERHUB_OIDC_CONNECTIONID` | String | | Docker Hub OIDC connection ID. Required for Docker Hub OIDC login |
|
||||||
|
| `DOCKERHUB_OIDC_EXPIREIN` | Number | `300` | Docker Hub OIDC token lifetime in seconds. Must be between `300` and `3600` |
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Want to contribute? Awesome! You can find information about contributing to
|
Want to contribute? Awesome! You can find information about contributing to
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {afterEach, expect, test} from 'vitest';
|
import {afterEach, expect, test, vi} from 'vitest';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
||||||
@@ -6,6 +6,7 @@ import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
|||||||
import {getAuthList, getInputs} from '../src/context.js';
|
import {getAuthList, getInputs} from '../src/context.js';
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
vi.restoreAllMocks();
|
||||||
for (const key of Object.keys(process.env)) {
|
for (const key of Object.keys(process.env)) {
|
||||||
if (key.startsWith('INPUT_')) {
|
if (key.startsWith('INPUT_')) {
|
||||||
delete process.env[key];
|
delete process.env[key];
|
||||||
@@ -33,3 +34,37 @@ test('getAuthList uses the default Docker Hub registry when computing scoped con
|
|||||||
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'myscope')
|
configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'myscope')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getAuthList skips secret masking when registry-auth password is absent', async () => {
|
||||||
|
const stdoutWriteSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
||||||
|
const [auth] = getAuthList({
|
||||||
|
registry: '',
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
scope: '',
|
||||||
|
ecr: '',
|
||||||
|
logout: true,
|
||||||
|
registryAuth: '- registry: public.ecr.aws\n'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(stdoutWriteSpy.mock.calls.map(call => call[0]).join('')).not.toContain('::add-mask::');
|
||||||
|
expect(auth).toMatchObject({
|
||||||
|
registry: 'public.ecr.aws',
|
||||||
|
ecr: 'auto'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getAuthList masks registry-auth password when present', async () => {
|
||||||
|
const stdoutWriteSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
||||||
|
getAuthList({
|
||||||
|
registry: '',
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
scope: '',
|
||||||
|
ecr: '',
|
||||||
|
logout: true,
|
||||||
|
registryAuth: '- registry: ghcr.io\n username: dbowie\n password: groundcontrol\n'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(stdoutWriteSpy.mock.calls.map(call => call[0]).join('')).toContain('::add-mask::groundcontrol');
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import {beforeEach, describe, expect, test, vi} from 'vitest';
|
||||||
|
|
||||||
|
import * as dockerhub from '../src/dockerhub.js';
|
||||||
|
|
||||||
|
vi.mock('@actions/core', () => ({
|
||||||
|
getIDToken: vi.fn(),
|
||||||
|
info: vi.fn(),
|
||||||
|
setSecret: vi.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
const validConnectionID = '123e4567-e89b-42d3-a456-426614174000';
|
||||||
|
|
||||||
|
const httpResponse = (statusCode: number, body: string, headers: Record<string, string> = {}): httpm.HttpClientResponse => {
|
||||||
|
return {
|
||||||
|
message: {
|
||||||
|
statusCode,
|
||||||
|
headers
|
||||||
|
},
|
||||||
|
readBody: vi.fn(async () => body)
|
||||||
|
} as unknown as httpm.HttpClientResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('isDockerHubOIDC', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
delete process.env.DOCKERHUB_OIDC_CONNECTIONID;
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['', 'docker.io', 'registry-1.docker.io', 'registry-1-stage.docker.io'])('detects Docker Hub registry %p with empty password', registry => {
|
||||||
|
process.env.DOCKERHUB_OIDC_CONNECTIONID = validConnectionID;
|
||||||
|
expect(dockerhub.isDockerHubOIDC(registry, '')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('requires connection ID env var', () => {
|
||||||
|
expect(dockerhub.isDockerHubOIDC('docker.io', '')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('requires empty password', () => {
|
||||||
|
process.env.DOCKERHUB_OIDC_CONNECTIONID = validConnectionID;
|
||||||
|
expect(dockerhub.isDockerHubOIDC('docker.io', 'groundcontrol')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ignores non-Docker Hub registries', () => {
|
||||||
|
process.env.DOCKERHUB_OIDC_CONNECTIONID = validConnectionID;
|
||||||
|
expect(dockerhub.isDockerHubOIDC('ghcr.io', '')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getOIDCToken', () => {
|
||||||
|
const getIDTokenMock = vi.mocked(core.getIDToken);
|
||||||
|
const setSecretMock = vi.mocked(core.setSecret);
|
||||||
|
let postSpy: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.DOCKERHUB_OIDC_CONNECTIONID = validConnectionID;
|
||||||
|
delete process.env.DOCKERHUB_OIDC_EXPIREIN;
|
||||||
|
getIDTokenMock.mockResolvedValue('github-id-token');
|
||||||
|
postSpy = vi.spyOn(httpm.HttpClient.prototype, 'post').mockResolvedValue(httpResponse(200, JSON.stringify({access_token: 'hub-token'})));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('exchanges GitHub OIDC token for Docker Hub token', async () => {
|
||||||
|
const credentials = await dockerhub.getOIDCToken('docker.io', 'dbowie');
|
||||||
|
|
||||||
|
expect(credentials).toEqual({
|
||||||
|
username: 'dbowie',
|
||||||
|
token: 'hub-token'
|
||||||
|
});
|
||||||
|
expect(getIDTokenMock).toHaveBeenCalledWith('https://identity.docker.com');
|
||||||
|
expect(postSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(postSpy.mock.calls[0][0]).toBe('https://identity.docker.com/oauth/token');
|
||||||
|
|
||||||
|
const http = postSpy.mock.contexts[0] as httpm.HttpClient;
|
||||||
|
expect(http.userAgent).toBe('github.com/docker/login-action');
|
||||||
|
expect(http.requestOptions?.headers).toEqual({
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
});
|
||||||
|
|
||||||
|
const body = new URLSearchParams(postSpy.mock.calls[0][1]);
|
||||||
|
expect(body.get('grant_type')).toBe('urn:ietf:params:oauth:grant-type:token-exchange');
|
||||||
|
expect(body.get('subject_token_type')).toBe('urn:ietf:params:oauth:token-type:id_token');
|
||||||
|
expect(body.get('subject_token')).toBe('github-id-token');
|
||||||
|
expect(body.get('connection_id')).toBe(validConnectionID);
|
||||||
|
expect(body.get('expires_in')).toBe('300');
|
||||||
|
expect(setSecretMock).toHaveBeenCalledWith('hub-token');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('uses custom token expiration', async () => {
|
||||||
|
process.env.DOCKERHUB_OIDC_EXPIREIN = '900';
|
||||||
|
await dockerhub.getOIDCToken('docker.io', 'dbowie');
|
||||||
|
const body = new URLSearchParams(postSpy.mock.calls[0][1]);
|
||||||
|
expect(body.get('expires_in')).toBe('900');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('uses stage identity host for stage registry', async () => {
|
||||||
|
await dockerhub.getOIDCToken('registry-1-stage.docker.io', 'dbowie');
|
||||||
|
expect(getIDTokenMock).toHaveBeenCalledWith('https://identity-stage.docker.com');
|
||||||
|
expect(postSpy.mock.calls[0][0]).toBe('https://identity-stage.docker.com/oauth/token');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('requires connection ID env var', async () => {
|
||||||
|
delete process.env.DOCKERHUB_OIDC_CONNECTIONID;
|
||||||
|
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow('DOCKERHUB_OIDC_CONNECTIONID is required for Docker Hub OIDC login');
|
||||||
|
expect(getIDTokenMock).not.toHaveBeenCalled();
|
||||||
|
expect(postSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('validates connection ID', async () => {
|
||||||
|
process.env.DOCKERHUB_OIDC_CONNECTIONID = 'not-a-uuid';
|
||||||
|
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow('Invalid DOCKERHUB_OIDC_CONNECTIONID. Must be a valid UUID.');
|
||||||
|
expect(getIDTokenMock).not.toHaveBeenCalled();
|
||||||
|
expect(postSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(['not-a-number', '299', '3601'])('validates token expiration %p', async expiresIn => {
|
||||||
|
process.env.DOCKERHUB_OIDC_EXPIREIN = expiresIn;
|
||||||
|
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresIn}. Must be between 300 and 3600`);
|
||||||
|
expect(getIDTokenMock).not.toHaveBeenCalled();
|
||||||
|
expect(postSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('retries rate limited token requests with Retry-After', async () => {
|
||||||
|
postSpy.mockResolvedValueOnce(httpResponse(429, '', {'retry-after': '0'})).mockResolvedValueOnce(httpResponse(200, JSON.stringify({access_token: 'hub-token'})));
|
||||||
|
await dockerhub.getOIDCToken('docker.io', 'dbowie');
|
||||||
|
expect(postSpy).toHaveBeenCalledTimes(2);
|
||||||
|
expect(core.info).toHaveBeenCalledWith('Docker Hub OIDC token request rate limited, retrying in 0ms (attempt 1/5)');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('throws Docker Hub API errors', async () => {
|
||||||
|
postSpy.mockResolvedValue(httpResponse(400, JSON.stringify({description: 'bad connection'})));
|
||||||
|
await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow('Docker Hub API: bad status code 400: bad connection');
|
||||||
|
});
|
||||||
|
});
|
||||||
+1
-1
@@ -17,7 +17,7 @@ FROM base AS deps
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn install && mkdir /vendor && cp yarn.lock /vendor
|
yarn install --immutable && mkdir /vendor && cp yarn.lock /vendor
|
||||||
|
|
||||||
FROM scratch AS vendor-update
|
FROM scratch AS vendor-update
|
||||||
COPY --from=deps /vendor /
|
COPY --from=deps /vendor /
|
||||||
|
|||||||
+176
-162
File diff suppressed because one or more lines are too long
+4
-4
File diff suppressed because one or more lines are too long
+361
-1830
File diff suppressed because it is too large
Load Diff
+11
-9
@@ -4,7 +4,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/main.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/index.cjs --sourcemap --minify && yarn run license",
|
"build": "esbuild src/main.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/index.cjs --sourcemap --minify --keep-names && yarn run license",
|
||||||
"lint": "eslint --max-warnings=0 .",
|
"lint": "eslint --max-warnings=0 .",
|
||||||
"format": "eslint --fix .",
|
"format": "eslint --fix .",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
@@ -21,15 +21,17 @@
|
|||||||
],
|
],
|
||||||
"author": "Docker Inc.",
|
"author": "Docker Inc.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "yarn@4.9.2",
|
"packageManager": "yarn@4.15.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.0",
|
"@actions/core": "^3.0.1",
|
||||||
"@aws-sdk/client-ecr": "^3.1020.0",
|
"@actions/http-client": "^4.0.1",
|
||||||
"@aws-sdk/client-ecr-public": "^3.1020.0",
|
"@aws-sdk/client-ecr": "^3.1077.0",
|
||||||
"@docker/actions-toolkit": "^0.86.0",
|
"@aws-sdk/client-ecr-public": "^3.1077.0",
|
||||||
"http-proxy-agent": "^9.0.0",
|
"@docker/actions-toolkit": "^0.93.0",
|
||||||
"https-proxy-agent": "^9.0.0",
|
"http-proxy-agent": "^9.1.0",
|
||||||
"js-yaml": "^4.1.1"
|
"https-proxy-agent": "^9.1.0",
|
||||||
|
"js-yaml": "^5.2.1",
|
||||||
|
"uuid": "^14.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.3",
|
"@eslint/js": "^9.39.3",
|
||||||
|
|||||||
+3
-1
@@ -53,7 +53,9 @@ export function getAuthList(inputs: Inputs): Array<Auth> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
auths = (yaml.load(inputs.registryAuth) as Array<Auth>).map(auth => {
|
auths = (yaml.load(inputs.registryAuth) as Array<Auth>).map(auth => {
|
||||||
core.setSecret(auth.password); // redacted in workflow logs
|
if (auth.password) {
|
||||||
|
core.setSecret(auth.password); // redacted in workflow logs
|
||||||
|
}
|
||||||
const registry = auth.registry || 'docker.io';
|
const registry = auth.registry || 'docker.io';
|
||||||
return {
|
return {
|
||||||
registry,
|
registry,
|
||||||
|
|||||||
+9
-1
@@ -4,12 +4,20 @@ import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
|||||||
|
|
||||||
import * as aws from './aws.js';
|
import * as aws from './aws.js';
|
||||||
import * as context from './context.js';
|
import * as context from './context.js';
|
||||||
|
import * as dockerhub from './dockerhub.js';
|
||||||
|
|
||||||
export async function login(auth: context.Auth): Promise<void> {
|
export async function login(auth: context.Auth): Promise<void> {
|
||||||
if (/true/i.test(auth.ecr) || (auth.ecr == 'auto' && aws.isECR(auth.registry))) {
|
if (/true/i.test(auth.ecr) || (auth.ecr == 'auto' && aws.isECR(auth.registry))) {
|
||||||
await loginECR(auth.registry, auth.username, auth.password, auth.scope);
|
await loginECR(auth.registry, auth.username, auth.password, auth.scope);
|
||||||
} else {
|
} else {
|
||||||
await loginStandard(auth.registry, auth.username, auth.password, auth.scope);
|
let username = auth.username;
|
||||||
|
let password = auth.password;
|
||||||
|
if (dockerhub.isDockerHubOIDC(auth.registry, password)) {
|
||||||
|
const credentials = await dockerhub.getOIDCToken(auth.registry, username);
|
||||||
|
username = credentials.username;
|
||||||
|
password = credentials.token;
|
||||||
|
}
|
||||||
|
await loginStandard(auth.registry, username, password, auth.scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import {HttpCodes} from '@actions/http-client';
|
||||||
|
import {validate as uuidValidate} from 'uuid';
|
||||||
|
|
||||||
|
export interface LoginCredentials {
|
||||||
|
username: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OIDCTokenResponse {
|
||||||
|
access_token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultExpiresIn = 300;
|
||||||
|
const minExpiresIn = 300;
|
||||||
|
const maxExpiresIn = 3600;
|
||||||
|
const maxRetries = 5;
|
||||||
|
|
||||||
|
export const isDockerHubOIDC = (registry: string, password: string): boolean => {
|
||||||
|
return process.env.DOCKERHUB_OIDC_CONNECTIONID !== undefined && !password && isDockerHubRegistry(registry);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isDockerHubRegistry = (registry: string): boolean => {
|
||||||
|
return registry === '' || registry === 'docker.io' || registry === 'registry-1.docker.io' || registry === 'registry-1-stage.docker.io';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getOIDCToken = async (registry: string, username: string): Promise<LoginCredentials> => {
|
||||||
|
const connectionID = process.env.DOCKERHUB_OIDC_CONNECTIONID?.trim();
|
||||||
|
if (!connectionID) {
|
||||||
|
throw new Error('DOCKERHUB_OIDC_CONNECTIONID is required for Docker Hub OIDC login');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uuidValidate(connectionID)) {
|
||||||
|
throw new Error('Invalid DOCKERHUB_OIDC_CONNECTIONID. Must be a valid UUID.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const expiresIn = getExpiresIn();
|
||||||
|
const identityHost = registry === 'registry-1-stage.docker.io' ? 'identity-stage.docker.com' : 'identity.docker.com';
|
||||||
|
const audience = `https://${identityHost}`;
|
||||||
|
const idToken = await core.getIDToken(audience);
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('github.com/docker/login-action', [], {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = new URLSearchParams();
|
||||||
|
data.set('grant_type', 'urn:ietf:params:oauth:grant-type:token-exchange');
|
||||||
|
data.set('subject_token_type', 'urn:ietf:params:oauth:token-type:id_token');
|
||||||
|
data.set('subject_token', idToken);
|
||||||
|
data.set('connection_id', connectionID);
|
||||||
|
data.set('expires_in', expiresIn.toString());
|
||||||
|
|
||||||
|
const resp = await postWithRetry(http, `https://${identityHost}/oauth/token`, data.toString());
|
||||||
|
|
||||||
|
const tokenResp = <OIDCTokenResponse>JSON.parse(await handleResponse(resp));
|
||||||
|
core.setSecret(tokenResp.access_token);
|
||||||
|
|
||||||
|
return {
|
||||||
|
username,
|
||||||
|
token: tokenResp.access_token
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getExpiresIn = (): number => {
|
||||||
|
const expiresInInput = process.env.DOCKERHUB_OIDC_EXPIREIN?.trim() || defaultExpiresIn.toString();
|
||||||
|
const expiresIn = Number(expiresInInput);
|
||||||
|
if (isNaN(expiresIn) || expiresIn < minExpiresIn || expiresIn > maxExpiresIn) {
|
||||||
|
throw new Error(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresInInput}. Must be between ${minExpiresIn} and ${maxExpiresIn}`);
|
||||||
|
}
|
||||||
|
return expiresIn;
|
||||||
|
};
|
||||||
|
|
||||||
|
const postWithRetry = async (http: httpm.HttpClient, url: string, data: string): Promise<httpm.HttpClientResponse> => {
|
||||||
|
let resp = await http.post(url, data);
|
||||||
|
for (let attempt = 0; (resp.message.statusCode || HttpCodes.InternalServerError) === HttpCodes.TooManyRequests && attempt < maxRetries; attempt++) {
|
||||||
|
const delay = parseRetryAfter(resp.message.headers['retry-after']);
|
||||||
|
if (delay === null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await resp.readBody();
|
||||||
|
core.info(`Docker Hub OIDC token request rate limited, retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay));
|
||||||
|
resp = await http.post(url, data);
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseRetryAfter = (value: string | string[] | undefined): number | null => {
|
||||||
|
if (value === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value = value[0];
|
||||||
|
}
|
||||||
|
const seconds = Number(value);
|
||||||
|
if (isNaN(seconds)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Math.max(0, seconds * 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleResponse = async (resp: httpm.HttpClientResponse): Promise<string> => {
|
||||||
|
const body = await resp.readBody();
|
||||||
|
const statusCode = resp.message.statusCode || HttpCodes.InternalServerError;
|
||||||
|
if (statusCode < HttpCodes.OK || statusCode >= HttpCodes.MultipleChoices) {
|
||||||
|
throw parseError(statusCode, body);
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseError = (statusCode: number, body: string): Error => {
|
||||||
|
if (statusCode === 401) {
|
||||||
|
throw new Error(`Docker Hub API: operation not permitted`);
|
||||||
|
}
|
||||||
|
if (body) {
|
||||||
|
const errResp = parseErrorBody(body);
|
||||||
|
for (const k of ['description', 'message', 'detail', 'error']) {
|
||||||
|
if (errResp[k]) {
|
||||||
|
throw new Error(`Docker Hub API: bad status code ${statusCode}: ${errResp[k]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Docker Hub API: bad status code ${statusCode}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseErrorBody = (body: string): Record<string, string> => {
|
||||||
|
try {
|
||||||
|
return <Record<string, string>>JSON.parse(body);
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user