-
Notifications
You must be signed in to change notification settings - Fork 14
130 lines (120 loc) · 3.91 KB
/
ci-images.yml
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
#
# CI for Image Builds
#
# This workflow builds all images on every PR and Push. It verifies that the
# images can be built successfully, and then possibly runs tests to verify
# their correct behavior.
#
# If triggered by the deploy-hooks, the built images will be pushed out to
# the configured registries.
#
name: "CI for Image Builds"
on:
pull_request:
push:
workflow_dispatch:
inputs:
target:
description: 'Image Target'
required: true
default: 'default'
jobs:
#
# Configure Jobs
#
# This job prepares parameters for the further builds. Amongst other things,
# it runs `make img-list` and provides this output as JSON array to other
# jobs. This allows us to dynamically react to additions to the image list
# and create new jobs for each image.
#
# Note that we have to split image builds across jobs since the individual
# CI runners do not have enough disk capacity to build all images.
#
config:
name: "Job Configuration"
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.parameters.outputs.deploy }}
images: ${{ steps.parameters.outputs.images }}
now: ${{ steps.parameters.outputs.now }}
steps:
- name: "Clone Repository"
uses: actions/checkout@v3
- name: "Determine Build Parameters"
id: parameters
env:
CTX_GITHUB_EVENT_NAME: ${{ github.event_name }}
CTX_GITHUB_EVENT_INPUTS_TARGET: ${{ github.event.inputs.target }}
IMG_DEPLOY: no
IMG_TARGET: all-images
run: |
if [[ "${CTX_GITHUB_EVENT_NAME}" = "workflow_dispatch" ]] ; then
IMG_DEPLOY="yes"
IMG_TARGET=${CTX_GITHUB_EVENT_INPUTS_TARGET}
fi
echo "deploy=${IMG_DEPLOY}" >>$GITHUB_OUTPUT
echo "images=$(make img-list)" >>$GITHUB_OUTPUT
echo "now=$(date -u '+%Y%m%d%H%M')" >>$GITHUB_OUTPUT
- name: "Print Parameters"
env:
CTX_STEPS_PARAMETERS_OUTPUTS_DEPLOY: ${{ steps.parameters.outputs.deploy }}
CTX_STEPS_PARAMETERS_OUTPUTS_IMAGES: ${{ steps.parameters.outputs.images }}
CTX_STEPS_PARAMETERS_OUTPUTS_NOW: ${{ steps.parameters.outputs.now }}
run: |
echo "Deploy: ${CTX_STEPS_PARAMETERS_OUTPUTS_DEPLOY}"
echo "Images:"
echo "${CTX_STEPS_PARAMETERS_OUTPUTS_IMAGES}" | jq .
echo "End of Images"
echo "Now: ${CTX_STEPS_PARAMETERS_OUTPUTS_NOW}"
#
# Build/Test Images
#
# This job is run for each image-target. It builds the image locally and then
# runs configured tests (if any).
#
ci:
name: "Image Build/Test"
runs-on: ubuntu-latest
needs: config
strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.config.outputs.images) }}
env:
OSB_UNIQUEID: ${{ needs.config.outputs.now }}
steps:
- name: "Clone Repository"
uses: actions/checkout@v3
- name: "Prepare QEMU Emulators"
uses: docker/setup-qemu-action@v2
- name: "Prepare Docker Buildx"
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.5.1
- name: "Build Image"
env:
IMG_BUILDER: ${{ steps.buildx.outputs.name }}
IMG_TARGET: ${{ matrix.image }}
run: make img-bake
- name: "Authenticate to GHCR"
if: ${{ needs.config.outputs.deploy == 'yes' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Authenticate to Quay"
if: ${{ needs.config.outputs.deploy == 'yes' }}
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: "Deploy Image & Mirror on Quay"
if: ${{ needs.config.outputs.deploy == 'yes' }}
env:
IMG_BAKE_ARGS: --push
IMG_BUILDER: ${{ steps.buildx.outputs.name }}
IMG_TARGET: ${{ matrix.image }}
run: make img-bake