-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (175 loc) · 6.09 KB
/
build_images.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
name: Build and push images
on:
pull_request: {}
push:
branches:
- 'main'
jobs:
find_directories:
name: Find directories with Dockerfiles
runs-on: ubuntu-20.04
outputs:
build_images: ${{ steps.find_directories.outputs.build_matrix }}
short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
branch_name: ${{ steps.versions.outputs.BRANCH_NAME }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- 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: Check out the tembo repo to reuse some actions
uses: actions/checkout@v3
with:
repository: tembo-io/tembo
path: ./.tembo
ref: 737713f5839bcd3f533644fe316540d890c611a8
- name: list dir
run: ls -la .tembo/.github/actions
- name: Find directories with Dockerfiles that changed
id: find_directories
uses: ./.tembo/.github/actions/find-changed-directories
with:
contains_the_file: Dockerfile
# If the branch does not exist, then it will not
# filter any directories containing the file.
# This allows for filtering out unchanged directories
# in a pull request, and using all directories on the release
# or main branches.
changed_relative_to_ref: origin/${{ github.base_ref || 'not-a-branch' }}
ignore_dirs: ".tembo, tembo-pg-slim, tembo-pg-cnpg"
build_and_push:
name: Build and push images
permissions:
id-token: write
contents: read
runs-on:
- self-hosted
- dind
- large-8x8
needs:
- find_directories
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.find_directories.outputs.build_images) }}
outputs:
short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set version strings
id: versions
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Determine which tags to publish
id: tags
run: |
BRANCH_NAME="${{ needs.find_directories.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: Build and upload image
uses: ./.github/actions/build-and-push-to-quay
with:
image_name: ${{ matrix.name }}
docker_directory: ${{ matrix.path }}
registry: "quay.io/tembo"
tag_cargo_version_if_present: ${{ steps.tags.outputs.tag_cargo }}
publish_latest: ${{ steps.tags.outputs.tag_latest }}
publish_calver: ${{ steps.tags_outputs.tag_latest }}
quay_user: ${{ secrets.QUAY_USER_TEMBO }}
quay_password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
quay_user_tembo: ${{ secrets.QUAY_USER_TEMBO }}
quay_password_tembo: ${{ secrets.QUAY_PASSWORD_TEMBO }}
gha_iam_role: ${{ secrets.GHA_IAM_ROLE }}
ecr_registry: ${{ secrets.ECR_REGISTRY }}
build_and_push_pg_slim:
name: Build and push tembo-pg-slim
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix:
include:
- pg_version: "14.10"
pg_major: "14"
- pg_version: "15.3"
pg_major: "15"
- pg_version: "16.1"
pg_major: "16"
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Build and push
run: |
set -xe
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
PUSH_FLAG=""
if [ "${BRANCH_NAME}" == "main" ]; then
PUSH_FLAG="--push"
fi
docker buildx build \
--build-arg PG_VERSION=${{ matrix.pg_version }} \
--build-arg PG_MAJOR=${{ matrix.pg_major }} \
--platform linux/amd64 \
--tag quay.io/tembo/tembo-pg-slim:pg${{ matrix.pg_major }} \
--pull ${PUSH_FLAG} ./tembo-pg-slim
build_and_push_pg_cnpg:
name: Build and push tembo-pg-cnpg
runs-on:
- self-hosted
- dind
- large-8x8
strategy:
fail-fast: false
matrix:
include:
- pg_version: "14"
- pg_version: "15"
- pg_version: "16"
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USER_TEMBO }}
password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
- name: Get short SHA
id: sha
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: Build and push
run: |
set -xe
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
PUSH_FLAG=""
if [ "${BRANCH_NAME}" == "main" ]; then
PUSH_FLAG="--push"
fi
docker buildx build \
--build-arg PG_VERSION=${{ matrix.pg_version }} \
--platform linux/amd64,linux/arm64 \
--tag quay.io/tembo/tembo-pg-cnpg:pg${{ matrix.pg_version }}-${{ steps.sha.outputs.sha }} \
--pull ${PUSH_FLAG} ./tembo-pg-cnpg