-
Notifications
You must be signed in to change notification settings - Fork 70
169 lines (156 loc) · 6.02 KB
/
ubi9-build.yaml
File metadata and controls
169 lines (156 loc) · 6.02 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
name: Build of UBI 9 based Developer Images
on:
push:
branches: [ main ]
workflow_dispatch:
workflow_call:
# Map the workflow outputs to job outputs
secrets:
QUAY_USERNAME:
required: true
QUAY_PASSWORD:
required: true
outputs:
uniq_tag:
description: "The first output string"
value: ${{ jobs.build_universal_ubi9_image.outputs.output1 }}
jobs:
build-base-image:
name: Build base image
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Free runner space
run: sudo rm -rf /usr/local/lib/android
- name: Cleanup docker images
run: docker system prune -af
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build base image
run: |
cd base/ubi9 && docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
--push \
-t quay.io/devfile/base-developer-image:${{env.arch}}-${{env.short_sha}} .
publish-base-image:
name: Publish base image
runs-on: ubuntu-22.04
needs: build-base-image
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: publish
run: |
for tag in latest ubi9-latest ubi9-${{env.short_sha}};
do
docker manifest create quay.io/devfile/base-developer-image:${tag} \
--amend quay.io/devfile/base-developer-image:amd64-${{env.short_sha}} \
--amend quay.io/devfile/base-developer-image:arm64-${{env.short_sha}}
docker manifest annotate quay.io/devfile/base-developer-image:${tag} \
quay.io/devfile/base-developer-image:amd64-${{env.short_sha}} \
--os linux --arch amd64
docker manifest annotate quay.io/devfile/base-developer-image:${tag} \
quay.io/devfile/base-developer-image:arm64-${{env.short_sha}} \
--os linux --arch arm64
docker manifest push quay.io/devfile/base-developer-image:${tag}
done
build-udi:
name: Build udi
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
needs: publish-base-image
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Free runner space
run: sudo rm -rf /usr/local/lib/android
- name: Cleanup docker images
run: docker system prune -af
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build udi
run: |
cd universal/ubi9 && docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
--push \
-t quay.io/devfile/universal-developer-image:${{env.arch}}-${{env.short_sha}} .
publish-udi:
name: Publish udi
runs-on: ubuntu-22.04
needs: build-udi
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: publish
run: |
for tag in latest ubi9-latest ubi9-${{env.short_sha}};
do
docker manifest create quay.io/devfile/universal-developer-image:${tag} \
--amend quay.io/devfile/universal-developer-image:amd64-${{env.short_sha}} \
--amend quay.io/devfile/universal-developer-image:arm64-${{env.short_sha}}
docker manifest annotate quay.io/devfile/universal-developer-image:${tag} \
quay.io/devfile/universal-developer-image:amd64-${{env.short_sha}} \
--os linux --arch amd64
docker manifest annotate quay.io/devfile/universal-developer-image:${tag} \
quay.io/devfile/universal-developer-image:arm64-${{env.short_sha}} \
--os linux --arch arm64
docker manifest push quay.io/devfile/universal-developer-image:${tag}
done
- name: Get tag with uniq prefix
id: setTagName
# set the image with uniq tag prefix (for example: quay.io/..../base-developer-image:ubi9-7ad6cab) to env. var
# and define it for output. This output with tag image will be used in caller job
run: |
echo "uniq_tag=quay.io/devfile/universal-developer-image:ubi9-${{env.short_sha}}" >> $GITHUB_OUTPUT