Skip to content

Commit 74bae29

Browse files
authored
fix: modified CI to push docker images to AWS ECR (#501)
1 parent 6f741ed commit 74bae29

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

.github/workflows/docker-build.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
image:
7-
description: "Docker image (e.g. docker.io/<org>/<repo>)"
7+
description: "Docker image (e.g. public.ecr.aws/supabase/<repo>)"
88
type: string
99
required: true
1010
checkout_ref:
@@ -35,10 +35,15 @@ on:
3535
description: "Build experimental image (main branch excluded)"
3636
type: boolean
3737
default: false
38+
secrets:
39+
PROD_AWS_ROLE:
40+
description: "AWS IAM role ARN for ECR push access"
41+
required: true
3842

3943
permissions:
4044
contents: read
4145
actions: write
46+
id-token: write
4247

4348
jobs:
4449
# Build each platform natively on its own runner
@@ -79,12 +84,18 @@ jobs:
7984
- name: Set up Docker Buildx
8085
uses: useblacksmith/setup-docker-builder@v1
8186

82-
- name: Log in to Docker Hub
87+
- name: Configure AWS credentials
88+
if: inputs.push == true
89+
uses: aws-actions/configure-aws-credentials@v4
90+
with:
91+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
92+
aws-region: us-east-1
93+
94+
- name: Log in to Amazon ECR Public
8395
if: inputs.push == true
8496
uses: docker/login-action@v3
8597
with:
86-
username: ${{ vars.DOCKERHUB_USERNAME }}
87-
password: ${{ secrets.DOCKERHUB_TOKEN }}
98+
registry: public.ecr.aws
8899

89100
- name: Build and Push Single-Platform Image
90101
id: build
@@ -139,11 +150,16 @@ jobs:
139150
- name: Set up Docker Buildx
140151
uses: useblacksmith/setup-docker-builder@v1
141152

142-
- name: Log in to Docker Hub
153+
- name: Configure AWS credentials
154+
uses: aws-actions/configure-aws-credentials@v4
155+
with:
156+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
157+
aws-region: us-east-1
158+
159+
- name: Log in to Amazon ECR Public
143160
uses: docker/login-action@v3
144161
with:
145-
username: ${{ vars.DOCKERHUB_USERNAME }}
146-
password: ${{ secrets.DOCKERHUB_TOKEN }}
162+
registry: public.ecr.aws
147163

148164
- name: Checkout (specific ref)
149165
if: inputs.checkout_ref != ''
@@ -196,8 +212,7 @@ jobs:
196212
TAGS="${TAGS}, v${{ inputs.version }}"
197213
fi
198214
fi
199-
HUB_PATH=$(echo "${IMAGE}" | sed -E 's@^docker\.io/@@')
200215
echo "✅ Successfully built and pushed ${NAME} multi-arch image (${MODE} mode)"
201216
echo "🏷️ Tags: ${TAGS}"
202217
echo "🏗️ Platforms: linux/amd64, linux/arm64"
203-
echo "🔗 View at: https://hub.docker.com/r/${HUB_PATH}"
218+
echo "🔗 View at: https://gallery.ecr.aws/supabase/${NAME}"

.github/workflows/docker-ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
permissions:
1919
contents: read
2020
actions: write
21-
21+
id-token: write
2222
jobs:
2323
resolve-ref:
2424
name: Resolve Checkout Ref
@@ -101,9 +101,10 @@ jobs:
101101
matrix:
102102
image: [etl-api, etl-replicator]
103103
uses: ./.github/workflows/docker-build.yml
104-
secrets: inherit
104+
secrets:
105+
PROD_AWS_ROLE: ${{ secrets.PROD_AWS_ROLE }}
105106
with:
106-
image: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}
107+
image: public.ecr.aws/supabase/${{ matrix.image }}
107108
context: .
108109
file: ./${{ matrix.image }}/Dockerfile
109110
push: true

.github/workflows/release.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
permissions:
1919
contents: write
2020
actions: write
21+
id-token: write
2122

2223
jobs:
2324
version:
@@ -107,14 +108,15 @@ jobs:
107108
image: [etl-api, etl-replicator]
108109
uses: ./.github/workflows/docker-build.yml
109110
with:
110-
image: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.image }}
111+
image: public.ecr.aws/supabase/${{ matrix.image }}
111112
context: .
112113
file: ./${{ matrix.image }}/Dockerfile
113114
push: true
114115
tag_with_version: true
115116
version: ${{ needs.version.outputs.version }}
116117
checkout_ref: refs/tags/${{ needs.version.outputs.tag }}
117-
secrets: inherit
118+
secrets:
119+
PROD_AWS_ROLE: ${{ secrets.PROD_AWS_ROLE }}
118120

119121
github-release:
120122
name: Create GitHub Release
@@ -126,21 +128,20 @@ jobs:
126128
shell: bash
127129
run: |
128130
set -euo pipefail
129-
USER="${{ vars.DOCKERHUB_USERNAME }}"
130131
TAG="${{ needs.version.outputs.tag }}"
131132
{
132133
echo "body<<MARKER"
133134
echo "Release ${TAG}"
134135
echo
135136
echo "Docker images published:"
136-
echo "- docker.io/${USER}/etl-api:latest"
137-
echo "- docker.io/${USER}/etl-api:${TAG}"
138-
echo "- docker.io/${USER}/etl-replicator:latest"
139-
echo "- docker.io/${USER}/etl-replicator:${TAG}"
137+
echo "- public.ecr.aws/supabase/etl-api:latest"
138+
echo "- public.ecr.aws/supabase/etl-api:${TAG}"
139+
echo "- public.ecr.aws/supabase/etl-replicator:latest"
140+
echo "- public.ecr.aws/supabase/etl-replicator:${TAG}"
140141
echo
141-
echo "View on Docker Hub:"
142-
echo "- https://hub.docker.com/r/${USER}/etl-api"
143-
echo "- https://hub.docker.com/r/${USER}/etl-replicator"
142+
echo "View on ECR Public Gallery:"
143+
echo "- https://gallery.ecr.aws/supabase/etl-api"
144+
echo "- https://gallery.ecr.aws/supabase/etl-replicator"
144145
echo "MARKER"
145146
} >> "$GITHUB_OUTPUT"
146147

0 commit comments

Comments
 (0)