mirror of
https://github.com/docker/login-action.git
synced 2026-07-25 03:02:01 +02:00
test: cover Docker Hub OIDC with registry-auth
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -648,6 +648,38 @@ jobs:
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
Docker Hub OIDC can also be used with `registry-auth`. Grant `id-token: write`,
|
||||
set `DOCKERHUB_OIDC_CONNECTIONID`, pass the Docker Hub organization name as
|
||||
`username`, and omit `password` for the Docker Hub object:
|
||||
|
||||
```yaml
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
login:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Login to registries
|
||||
uses: docker/login-action@v4
|
||||
env:
|
||||
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
|
||||
with:
|
||||
registry-auth: |
|
||||
- username: ${{ vars.DOCKERHUB_ORGANIZATION }}
|
||||
- registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Set scopes for the authentication token
|
||||
|
||||
The `scope` input allows limiting registry credentials to a specific repository
|
||||
|
||||
Reference in New Issue
Block a user