-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (192 loc) · 7.28 KB
/
multi-build-push-postgres.yml
File metadata and controls
224 lines (192 loc) · 7.28 KB
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
# This is based on multi-build-push.yml but includes a number of changes
name: build and push on main
on:
push:
branches:
- main
pull_request:
env:
GITHUB_ROLE_ARN: arn:aws:iam::461800378586:role/GitHubECRPublic
permissions:
id-token: write # Required for OIDC
contents: read # This is required for actions/checkout
jobs:
build_and_push:
strategy:
matrix:
version: ["14-debian13"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get repo name
id: image_name
run: |
sed -E -e 's/docker-//' -e 's/^/image_name=/' <<<"${{ github.repository }}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# The values provided to these two AWS steps are always the same for Panubo owned repos
- name: Configure AWS Credentials
if: github.event_name != 'pull_request'
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ env.GITHUB_ROLE_ARN }}
aws-region: us-east-1
- name: Login to ECR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Login to Quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.PANUBUILD_QUAYIO_USERNAME }}
password: ${{ secrets.PANUBUILD_QUAYIO_TOKEN }}
- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.7.0
- name: Build and export to Docker
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./${{ matrix.version }}
cache-from: type=gha
load: true
tags: ${{ steps.image_name.outputs.image_name }}:test
- name: Test
run: |
cd ${{ matrix.version }}
make _ci_test
- name: Get image version(s)
id: image_version
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
run: |
cd ${{ matrix.version }}
delimiter="$(openssl rand -hex 8)"
echo "image_version<<${delimiter}" >> "${GITHUB_OUTPUT}"
make _ci_version TAG=test REGISTRY=docker.io >> "${GITHUB_OUTPUT}" # This Make target inspects the built image. Some additional options are passed in.
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
quay.io/${{ steps.image_name.outputs.image_name }}
public.ecr.aws/${{ steps.image_name.outputs.image_name }}
# generate Docker tags based on the following events/attributes
tags: |
${{ steps.image_version.outputs.image_version }}
# type=schedule
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=sha
- name: Build and Push
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./${{ matrix.version }}
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# build_and_push_upgrade:
# needs: [build_and_push]
# strategy:
# matrix:
# version: ["12-to-14-upgrade"]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Get repo name
# id: image_name
# run: |
# sed -E -e 's/docker-//' -e 's/^/image_name=/' <<<"${{ github.repository }}" >> "$GITHUB_OUTPUT"
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# id: buildx
# uses: docker/setup-buildx-action@v2
# # The values provided to these two AWS steps are always the same for Panubo owned repos
# - name: Configure AWS Credentials
# if: github.event_name != 'pull_request'
# uses: aws-actions/configure-aws-credentials@v1-node16
# with:
# role-to-assume: ${{ env.GITHUB_ROLE_ARN }}
# aws-region: us-east-1
# - name: Login to ECR
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v2
# with:
# registry: public.ecr.aws
# - name: Login to Quay.io
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v2
# with:
# registry: quay.io
# username: ${{ secrets.PANUBUILD_QUAYIO_USERNAME }}
# password: ${{ secrets.PANUBUILD_QUAYIO_TOKEN }}
# - name: Setup BATS
# uses: mig4/setup-bats@v1
# with:
# bats-version: 1.7.0
# - name: Build and export to Docker
# uses: docker/build-push-action@v4
# with:
# builder: ${{ steps.buildx.outputs.name }}
# context: ./${{ matrix.version }}
# cache-from: type=gha
# load: true
# tags: ${{ steps.image_name.outputs.image_name }}:test
# - name: Test
# run: |
# cd ${{ matrix.version }}
# make _ci_test
# - name: Get image version(s)
# id: image_version
# # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
# run: |
# cd ${{ matrix.version }}
# delimiter="$(openssl rand -hex 8)"
# echo "image_version<<${delimiter}" >> "${GITHUB_OUTPUT}"
# make _ci_version >> "${GITHUB_OUTPUT}"
# echo "${delimiter}" >> "${GITHUB_OUTPUT}"
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v4
# with:
# # list of Docker images to use as base name for tags
# images: |
# quay.io/${{ steps.image_name.outputs.image_name }}
# public.ecr.aws/${{ steps.image_name.outputs.image_name }}
# # generate Docker tags based on the following events/attributes
# tags: |
# ${{ steps.image_version.outputs.image_version }}
# # type=schedule
# # type=ref,event=branch
# # type=ref,event=pr
# # type=semver,pattern={{version}}
# # type=semver,pattern={{major}}.{{minor}}
# # type=sha
# - name: Build and Push
# uses: docker/build-push-action@v3
# with:
# builder: ${{ steps.buildx.outputs.name }}
# context: ./${{ matrix.version }}
# push: ${{ github.event_name != 'pull_request' }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
# platforms: linux/amd64,linux/arm64
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}