Skip to content

Commit 2be76f4

Browse files
committed
chore: matrix on version and arch in build_release_image
1 parent 6bd45b1 commit 2be76f4

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

.github/workflows/dockerhub-release-matrix.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ jobs:
6161
matrix: ${{ fromJson(needs.prepare.outputs.matrix_config) }}
6262
runs-on: ubuntu-latest
6363
outputs:
64-
image_tag: supabase/postgres:${{ steps.settings.outputs.postgres-version }}
64+
versions: ${{ steps.output-versions.outputs.versions }}
65+
image_tags: ${{ steps.output-versions.outputs.image_tags }}
6566
build_args: ${{ steps.args.outputs.result }}
6667
steps:
6768
- uses: actions/checkout@v3
@@ -76,7 +77,6 @@ jobs:
7677
PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres${{ matrix.version }}"]' ansible/vars.yml)
7778
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
7879
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
79-
# Ensure there's a newline at the end of the file
8080
echo "" >> common-nix.vars.pkr.hcl
8181
8282
- id: settings
@@ -87,19 +87,25 @@ jobs:
8787
with:
8888
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'
8989

90+
- id: output-versions
91+
run: |
92+
# Create JSON arrays for versions and image tags
93+
echo "versions=$(echo '${{ toJSON(matrix.version) }}')" >> $GITHUB_OUTPUT
94+
echo "image_tags=$(echo 'supabase/postgres:${{ steps.settings.outputs.postgres-version }}')" >> $GITHUB_OUTPUT
95+
9096
build_release_image:
9197
needs: [build]
9298
strategy:
9399
matrix:
100+
version: ${{ fromJson(needs.build.outputs.versions) }}
101+
image_tag: ${{ fromJson(needs.build.outputs.image_tags) }}
94102
include:
95-
- runner: [self-hosted, X64]
96-
arch: amd64
97-
- runner: arm-runner
98-
arch: arm64
103+
- arch: amd64
104+
runner: [self-hosted, X64]
105+
- arch: arm64
106+
runner: arm-runner
99107
runs-on: ${{ matrix.runner }}
100108
timeout-minutes: 180
101-
outputs:
102-
image_digest: ${{ steps.build.outputs.digest }}
103109
steps:
104110
- run: docker context create builders
105111
- uses: docker/setup-buildx-action@v3
@@ -116,11 +122,11 @@ jobs:
116122
build-args: |
117123
${{ needs.build.outputs.build_args }}
118124
target: production
119-
tags: ${{ needs.build.outputs.image_tag }}_${{ matrix.arch }}
125+
tags: ${{ matrix.image_tag }}_${{ matrix.arch }}
120126
platforms: linux/${{ matrix.arch }}
121127
cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
122128
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
123-
file: ${{ matrix.dockerfile }}
129+
file: Dockerfile-${{ matrix.version }}
124130
- name: Slack Notification
125131
if: ${{ failure() }}
126132
uses: rtCamp/action-slack-notify@v2
@@ -133,6 +139,9 @@ jobs:
133139

134140
merge_manifest:
135141
needs: [build, build_release_image]
142+
strategy:
143+
matrix:
144+
image_tag: ${{ fromJson(needs.build.outputs.image_tags) }}
136145
runs-on: ubuntu-latest
137146
steps:
138147
- uses: docker/setup-buildx-action@v3
@@ -142,9 +151,9 @@ jobs:
142151
password: ${{ secrets.DOCKER_PASSWORD }}
143152
- name: Merge multi-arch manifests
144153
run: |
145-
docker buildx imagetools create -t ${{ needs.build.outputs.image_tag }} \
146-
${{ needs.build.outputs.image_tag }}_amd64 \
147-
${{ needs.build.outputs.image_tag }}_arm64
154+
docker buildx imagetools create -t ${{ matrix.image_tag }} \
155+
${{ matrix.image_tag }}_amd64 \
156+
${{ matrix.image_tag }}_arm64
148157
- name: Slack Notification
149158
if: ${{ failure() }}
150159
uses: rtCamp/action-slack-notify@v2
@@ -160,4 +169,4 @@ jobs:
160169
uses: ./.github/workflows/mirror.yml
161170
with:
162171
version: ${{ needs.build.outputs.docker_version }}
163-
secrets: inherit
172+
secrets: inherit

0 commit comments

Comments
 (0)