follow-up docker/buildx#3562
Adds scope input to create alternative Docker config on login that will be used by Buildx.
Example to scope auth token to specific repo:
login:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
scope: docker/buildx-bin
Docker config files on GitHub Runner:
## /home/runner/.docker/buildx/config/registry-1.docker.io/docker/buildx-bin/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "REDACTED"
}
}
}
## /home/runner/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "REDACTED"
}
}
}
/home/runner/.docker/config.json is the default one available on the runner.
Other example with scope auth token to specific repo and only push:
login:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
scope: docker/buildx-bin@push
Docker config files on GitHub Runner:
## /home/runner/.docker/buildx/config/registry-1.docker.io/docker/buildx-bin@push/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "REDACTED"
}
}
}
## /home/runner/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "REDACTED"
}
}
}