-
Notifications
You must be signed in to change notification settings - Fork 90
179 lines (167 loc) · 6.11 KB
/
caa_build_and_push.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
name: (Callable) Build and push cloud-api-adaptor image
on:
workflow_call:
inputs:
registry:
default: 'quay.io/confidential-containers'
description: 'Image registry (e.g. "ghcr.io/confidential-containers") where the built image will be pushed to'
required: false
type: string
dev_arches:
default: 'linux/amd64'
description: 'Dev build arches. Expected a docker buildx "--platform" string format'
required: false
type: string
dev_tags:
default: ''
description: 'Comma-separated list of tags for the dev built image (e.g. latest,ci-dev). By default uses the values from hack/build.sh'
required: false
type: string
release_arches:
default: 'linux/amd64,linux/s390x,linux/ppc64le'
description: 'Release build arches. Expected a docker buildx "--platform" string format'
required: false
type: string
release_tags:
default: ''
description: 'Likewise but for the release built image'
required: false
type: string
git_ref:
default: 'image-action'
description: Git ref to checkout the cloud-api-adaptor repository. Defaults to main.
required: false
type: string
jobs:
build_push_job:
name: build and push
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- type: dev-amd64
arches: "linux/amd64"
#- type: dev-s390x
# arches: "linux/s390x"
#- type: dev-ppc64le
# arches: "linux/ppc64le"
- type: release-amd64
arches: "linux/amd64"
#- type: release-s390x
# arches: "linux/s390x"
#- type: release-ppc64le
# arches: "linux/ppc64le"
steps:
- name: Checkout the code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: "${{ inputs.git_ref }}"
- name: Read properties from versions.yaml
run: |
go_version="$(yq '.tools.golang' versions.yaml)"
[ -n "$go_version" ]
echo "GO_VERSION=${go_version}" >> "$GITHUB_ENV"
- name: Setup Golang version ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install build dependencies
if: ${{ startsWith(matrix.type, 'dev-') }}
run: |
sudo apt-get update -y
sudo apt-get install -y libvirt-dev
- name: Login to quay Container Registry
if: ${{ startsWith(inputs.registry, 'quay.io') }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ startsWith(inputs.registry, 'ghcr.io') }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push dev image
if: ${{ startsWith(matrix.type, 'dev-') }}
- uses: nick-fields/retry@v2
with:
# We are not interested in timeout but this field is required
# so setting to 4x the time it usually take to complete.
timeout_minutes: 60
retry_wait_seconds: 120
max_attempts: 3
command: |
echo "Build and push dev image with libvirt"
ARCHES=${{matrix.arches}} RELEASE_BUILD=false DEV_TAGS=${{ inputs.dev_tags}} make image registry=${{ inputs.registry }}
hack/image-manifest.sh -w
- uses: actions/upload-artifact@v3
with:
name: my-artifact
path: |
cloud-api-adaptor*.tar
commits.txt
- name: Build and push release image
if: ${{ startsWith(matrix.type, 'release-') }}
- uses: nick-fields/retry@v2
with:
# We are not interested in timeout but this field is required
# so setting to 4x the time it usually take to complete.
timeout_minutes: 60
retry_wait_seconds: 120
max_attempts: 3
command: |
echo "Build and push release image without libvirt"
ARCHES=${{matrix.arches}} RELEASE_BUILD=true RELEASE_TAGS=${{ inputs.release_tags}} make image registry=${{ inputs.registry }}
hack/image-manifest.sh -w
- uses: actions/upload-artifact@v3
with:
name: my-artifact
path: |
cloud-api-adaptor*.tar
commits.txt
- name: 'Generate release commits file'
if: ${{ contains(matrix.type, 'dev-amd64') }}
command: |
TODO
- name: 'Upload release commits file'
if: ${{ contains(matrix.type, 'dev-amd64') }}
uses: actions/upload-artifact@v3
with:
name: release-commits-artifact
path: commits.txt
retention-days: 7
manifest_job:
name: generate images manifest
runs-on: ubuntu-latest
needs: [build_push_job]
steps:
- name: Download release commits file
uses: actions/download-artifact@v3
with:
name: my-artifact
path: |
cloud-api-adaptor*.tar
commits.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to quay Container Registry
if: ${{ startsWith(inputs.registry, 'quay.io') }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ startsWith(inputs.registry, 'ghcr.io') }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}