-
Notifications
You must be signed in to change notification settings - Fork 0
287 lines (281 loc) · 11.1 KB
/
build_tembo_pg_slim.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: build-tembo-pg-slim
on:
push:
branches:
- main
paths:
- 'tembo-pg-slim/**'
pull_request:
branches:
- main
paths:
- 'tembo-pg-slim/**'
jobs:
pre-build:
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
branch_name: ${{ steps.versions.outputs.BRANCH_NAME }}
build_matrix: ${{ steps.append_pg_configs.outputs.build_matrix }}
tags: ${{ steps.tags.outputs.tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set version strings
id: versions
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Append PostgreSQL configurations to matrix
id: append_pg_configs
run: |
PG_CONFIGS='[{"pg_release": "14.10", "pg_version": "14"}, {"pg_release": "15.3", "pg_version": "15"}, {"pg_release": "16.1", "pg_version": "16"}]'
MODIFIED_MATRIX=$(echo $PG_CONFIGS | jq -c '{include: .}')
echo "build_matrix=$MODIFIED_MATRIX" >> $GITHUB_OUTPUT
- name: Determine which tags to publish
id: tags_list
run: |
BRANCH_NAME="${{ steps.versions.outputs.BRANCH_NAME }}"
if [ "${BRANCH_NAME}" == "main" ]; then
echo "tag_latest=true" >> $GITHUB_OUTPUT
echo "tag_cargo=true" >> $GITHUB_OUTPUT
elif [[ "${BRANCH_NAME}" == release/* ]]; then
echo "tag_cargo=true" >> $GITHUB_OUTPUT
echo "tag_latest=false" >> $GITHUB_OUTPUT
else
echo "tag_latest=false" >> $GITHUB_OUTPUT
echo "tag_cargo=false" >> $GITHUB_OUTPUT
fi
- name: Install TOML parser
run: |
set -xe
wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64
mv stoml_linux_amd64 stoml
chmod +x stoml
sudo mv stoml /usr/local/bin/
- name: Create whitespace-separated tags list
id: tags
run: |
SHORT_SHA="${{ steps.versions.outputs.SHORT_SHA }}"
TAGS=''
if [ "${{ steps.tags_list.outputs.tag_cargo }}" == "true" ]; then
echo "Cargo file detected, adding to tags"
VERSION=$(stoml Cargo.toml package.version)-${SHORT_SHA}
TAGS="$TAGS $VERSION"
fi
if [ "${{ steps.tags_list.outputs.tag_latest }}" == "true" ]; then
TAGS="$TAGS latest"
fi
TAGS="$TAGS ${SHORT_SHA}"
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Debug outputs
run: |
echo "Short SHA: ${{ steps.versions.outputs.SHORT_SHA }}"
echo "Branch Name: ${{ steps.versions.outputs.BRANCH_NAME }}"
echo "Build Matrix: ${{ steps.append_pg_configs.outputs.build_matrix }}"
echo "Tags: ${{ steps.tags.outputs.tags }}"
tembo-pg-slim-build:
needs: pre-build
permissions:
id-token: write
contents: read
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}}
env:
CONTAINER_NAME: "tembo-pg-slim"
steps:
- uses: actions/checkout@v4
- name: Build Docker images based on conditions
run: |
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} -t $IMAGE_NAME
shell: bash
- name: Login to Tembo Quay
uses: docker/login-action@v2
with:
registry: ${{ secrets.QUAY_REPOSITORY }}
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Push to Quay
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
done
standard-cnpg-build:
needs: [pre-build, tembo-pg-slim-build]
permissions:
id-token: write
contents: read
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}}
env:
CONTAINER_NAME: "standard-cnpg"
steps:
- uses: actions/checkout@v4
- name: Build Docker images based on conditions
run: |
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME
shell: bash
- name: Login to Tembo Quay
uses: docker/login-action@v2
with:
registry: ${{ secrets.QUAY_REPOSITORY }}
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Push to Quay
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
done
- name: Configure AWS credentials for ECR
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GHA_IAM_ROLE }}
role-session-name: images-gha-docker-build-and-push
aws-region: "us-east-1"
- name: Install awscli
uses: unfor19/install-aws-cli-action@v1
- name: Push to ECR
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME
docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
done
ml-cnpg-build:
needs: [pre-build, standard-cnpg-build]
permissions:
id-token: write
contents: read
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}}
env:
CONTAINER_NAME: "ml-cnpg"
steps:
- uses: actions/checkout@v4
- name: Build Docker images based on conditions
run: |
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME
shell: bash
- name: Login to Tembo Quay
uses: docker/login-action@v2
with:
registry: ${{ secrets.QUAY_REPOSITORY }}
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Push to Quay
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
done
- name: Configure AWS credentials for ECR
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GHA_IAM_ROLE }}
role-session-name: images-gha-docker-build-and-push
aws-region: "us-east-1"
- name: Install awscli
uses: unfor19/install-aws-cli-action@v1
- name: Push to ECR
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME
docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
done
dw-cnpg-build:
needs: [pre-build, standard-cnpg-build]
permissions:
id-token: write
contents: read
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}}
env:
CONTAINER_NAME: "dw-cnpg"
steps:
- uses: actions/checkout@v4
- name: Build Docker images based on conditions
run: |
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME
shell: bash
- name: Login to Tembo Quay
uses: docker/login-action@v2
with:
registry: ${{ secrets.QUAY_REPOSITORY }}
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Push to Quay
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag
done
- name: Configure AWS credentials for ECR
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GHA_IAM_ROLE }}
role-session-name: images-gha-docker-build-and-push
aws-region: "us-east-1"
- name: Install awscli
uses: unfor19/install-aws-cli-action@v1
- name: Push to ECR
shell: bash
run: |
set -xe
IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }}
IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}"
for tag in "${TAG_ARRAY[@]}"; do
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME
docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag
done