1
+ name : Release all major versions on Dockerhub
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - develop
7
+ - release/*
8
+ - sam/docker-oriole17
9
+ paths :
10
+ - " .github/workflows/dockerhub-release-matrix.yml"
11
+ - " anisble/vars.yml"
12
+ workflow_dispatch :
13
+
14
+ jobs :
15
+ prepare :
16
+ runs-on : ubuntu-latest
17
+ outputs :
18
+ matrix_config : ${{ steps.set-matrix.outputs.matrix_config }}
19
+ steps :
20
+ - name : Checkout Repo
21
+ uses : actions/checkout@v3
22
+
23
+ - uses : DeterminateSystems/nix-installer-action@main
24
+
25
+ - name : Generate build matrix
26
+ id : set-matrix
27
+ run : |
28
+ # Get all postgres versions from vars.yml
29
+ VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml)
30
+
31
+ # Check which versions have corresponding Dockerfiles and create matrix config
32
+ MATRIX_CONFIG="{"
33
+ MATRIX_CONFIG+="\"include\":["
34
+ FIRST=true
35
+
36
+ while IFS= read -r version; do
37
+ # Remove quotes from version
38
+ version=$(echo "$version" | tr -d '"')
39
+
40
+ # Determine dockerfile name based on version
41
+ if [[ "$version" == "orioledb-"* ]]; then
42
+ dockerfile="Dockerfile-${version#orioledb-}-orioledb"
43
+ else
44
+ dockerfile="Dockerfile-${version}"
45
+ fi
46
+
47
+ # Check if Dockerfile exists
48
+ if [ -f "$dockerfile" ]; then
49
+ if [ "$FIRST" = true ]; then
50
+ FIRST=false
51
+ else
52
+ MATRIX_CONFIG+=","
53
+ fi
54
+ MATRIX_CONFIG+="{\"version\":\"$version\",\"dockerfile\":\"$dockerfile\"}"
55
+ fi
56
+ done <<< "$VERSIONS"
57
+
58
+ MATRIX_CONFIG+="]}"
59
+
60
+ # Output the matrix configuration
61
+ echo "matrix_config=$MATRIX_CONFIG" >> $GITHUB_OUTPUT
62
+
63
+ build :
64
+ needs : prepare
65
+ strategy :
66
+ matrix : ${{ fromJson(needs.prepare.outputs.matrix_config) }}
67
+ runs-on : ubuntu-latest
68
+ outputs :
69
+ image_tag : supabase/postgres:${{ steps.settings.outputs.postgres-version }}
70
+ build_args : ${{ steps.args.outputs.result }}
71
+ steps :
72
+ - uses : actions/checkout@v3
73
+ - id : settings
74
+ run : sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT
75
+ - id : args
76
+ uses : mikefarah/yq@master
77
+ with :
78
+ cmd : yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'
79
+
80
+ build_release_image :
81
+ needs : [build]
82
+ strategy :
83
+ matrix :
84
+ include :
85
+ - runner : [self-hosted, X64]
86
+ arch : amd64
87
+ - runner : arm-runner
88
+ arch : arm64
89
+ runs-on : ${{ matrix.runner }}
90
+ timeout-minutes : 180
91
+ outputs :
92
+ image_digest : ${{ steps.build.outputs.digest }}
93
+ steps :
94
+ - run : docker context create builders
95
+ - uses : docker/setup-buildx-action@v3
96
+ with :
97
+ endpoint : builders
98
+ - uses : docker/login-action@v2
99
+ with :
100
+ username : ${{ secrets.DOCKER_USERNAME }}
101
+ password : ${{ secrets.DOCKER_PASSWORD }}
102
+ - id : build
103
+ uses : docker/build-push-action@v5
104
+ with :
105
+ push : true
106
+ build-args : |
107
+ ${{ needs.build.outputs.build_args }}
108
+ target : production
109
+ tags : ${{ needs.build.outputs.image_tag }}_${{ matrix.arch }}
110
+ platforms : linux/${{ matrix.arch }}
111
+ cache-from : type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
112
+ cache-to : type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
113
+ file : ${{ matrix.dockerfile }}
114
+ - name : Slack Notification
115
+ if : ${{ failure() }}
116
+ uses : rtCamp/action-slack-notify@v2
117
+ env :
118
+ SLACK_WEBHOOK : ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
119
+ SLACK_USERNAME : " gha-failures-notifier"
120
+ SLACK_COLOR : " danger"
121
+ SLACK_MESSAGE : " Building Postgres ${{ matrix.arch }} image failed for version ${{ matrix.version }}"
122
+ SLACK_FOOTER : " "
123
+
124
+ merge_manifest :
125
+ needs : [build, build_release_image]
126
+ runs-on : ubuntu-latest
127
+ steps :
128
+ - uses : docker/setup-buildx-action@v3
129
+ - uses : docker/login-action@v2
130
+ with :
131
+ username : ${{ secrets.DOCKER_USERNAME }}
132
+ password : ${{ secrets.DOCKER_PASSWORD }}
133
+ - name : Merge multi-arch manifests
134
+ run : |
135
+ docker buildx imagetools create -t ${{ needs.build.outputs.image_tag }} \
136
+ ${{ needs.build.outputs.image_tag }}_amd64 \
137
+ ${{ needs.build.outputs.image_tag }}_arm64
138
+ - name : Slack Notification
139
+ if : ${{ failure() }}
140
+ uses : rtCamp/action-slack-notify@v2
141
+ env :
142
+ SLACK_WEBHOOK : ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
143
+ SLACK_USERNAME : " gha-failures-notifier"
144
+ SLACK_COLOR : " danger"
145
+ SLACK_MESSAGE : " Building Postgres image failed for version ${{ matrix.version }}"
146
+ SLACK_FOOTER : " "
147
+
148
+ publish :
149
+ needs : [build, merge_manifest]
150
+ uses : ./.github/workflows/mirror.yml
151
+ with :
152
+ version : ${{ needs.build.outputs.docker_version }}
153
+ secrets : inherit
0 commit comments