Skip to content

Commit e6d8f9e

Browse files
committed
chore(ci): authenticate Docker Hub via OIDC
Use separate read-only and read/write Docker Hub connections for private-fork pulls and upstream image publishing, removing the workflow dependency on a long-lived Docker Hub token.
1 parent 4933384 commit e6d8f9e

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

.github/workflows/docker.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
images: |
6969
${{ env.REGISTRY }}/tempo
70-
docker.io/tempoxyz/tempo
70+
${{ github.repository == 'tempoxyz/tempo' && 'docker.io/tempoxyz/tempo' || '' }}
7171
bake-target: tempo
7272
labels: ${{ steps.docker-labels.outputs.value }}
7373
tags: |
@@ -88,7 +88,7 @@ jobs:
8888
with:
8989
images: |
9090
${{ env.REGISTRY }}/tempo-localnet
91-
docker.io/tempoxyz/tempo-localnet
91+
${{ github.repository == 'tempoxyz/tempo' && 'docker.io/tempoxyz/tempo-localnet' || '' }}
9292
bake-target: tempo-localnet
9393
labels: ${{ steps.docker-labels.outputs.value }}
9494
tags: |
@@ -109,7 +109,7 @@ jobs:
109109
with:
110110
images: |
111111
${{ env.REGISTRY }}/tempo-sidecar
112-
docker.io/tempoxyz/tempo-sidecar
112+
${{ github.repository == 'tempoxyz/tempo' && 'docker.io/tempoxyz/tempo-sidecar' || '' }}
113113
bake-target: tempo-sidecar
114114
labels: ${{ steps.docker-labels.outputs.value }}
115115
tags: |
@@ -130,7 +130,7 @@ jobs:
130130
with:
131131
images: |
132132
${{ env.REGISTRY }}/tempo-xtask
133-
docker.io/tempoxyz/tempo-xtask
133+
${{ github.repository == 'tempoxyz/tempo' && 'docker.io/tempoxyz/tempo-xtask' || '' }}
134134
bake-target: tempo-xtask
135135
labels: ${{ steps.docker-labels.outputs.value }}
136136
tags: |
@@ -152,11 +152,35 @@ jobs:
152152
username: ${{ github.actor }}
153153
password: ${{ secrets.GITHUB_TOKEN }}
154154

155-
- name: Log in to Docker Hub
156-
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
155+
- name: Require Docker Hub write OIDC configuration
156+
if: github.repository == 'tempoxyz/tempo' && vars.DOCKERHUB_OIDC_CONNECTIONID_WRITE == ''
157+
run: |
158+
echo "::error::The DOCKERHUB_OIDC_CONNECTIONID_WRITE repository variable is not set."
159+
exit 1
160+
161+
- name: Log in to Docker Hub via OIDC (read/write)
162+
if: github.repository == 'tempoxyz/tempo'
163+
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
164+
env:
165+
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID_WRITE }}
166+
with:
167+
username: tempoxyz
168+
169+
- name: Require Docker Hub read OIDC configuration
170+
if: github.repository == 'tempoxyz/tempo-private-fork' && vars.DOCKERHUB_OIDC_CONNECTIONID_READ == ''
171+
run: |
172+
echo "::error::The DOCKERHUB_OIDC_CONNECTIONID_READ repository variable is not set."
173+
exit 1
174+
175+
# Private-fork builds publish only to GHCR. Docker Hub authentication is
176+
# read-only and used for authenticated base-image pulls.
177+
- name: Log in to Docker Hub via OIDC (read-only)
178+
if: github.repository == 'tempoxyz/tempo-private-fork'
179+
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
180+
env:
181+
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID_READ }}
157182
with:
158-
username: ${{ vars.DOCKER_HUB_USER }}
159-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
183+
username: tempoxyz
160184

161185
- id: shortsha
162186
run: echo "shortsha=$(echo ${{ github.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)