-
Notifications
You must be signed in to change notification settings - Fork 19
236 lines (210 loc) · 8.03 KB
/
release-series-builds.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
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
225
226
227
228
229
230
231
232
233
234
235
236
---
name: Build release series tagged images
on:
push:
branches:
- master
pull_request:
branches:
- '**'
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:
jobs:
base-image-build:
name: xcache:${{ matrix.osg_series.name }}-${{ matrix.repo }} image build
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
steps:
- uses: actions/checkout@v3
- name: Cache base image
uses: actions/cache@v3
with:
path: /tmp/.base-buildx-cache
key: base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-${{ github.sha }}-${{ github.run_id }}
# allow cache hits from previous runs of the current branch,
# parent branch, then upstream branches, in that order
restore-keys: |
base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
pull: True
target: xcache
cache-to: type=local,dest=/tmp/.base-buildx-cache,mode=max
xcache-image-builds:
name: ${{ matrix.image }}:${{ matrix.osg_series.name }}-${{ matrix.repo }} image build
needs: [base-image-build]
strategy:
fail-fast: False
matrix:
image: [atlas-xcache, cms-xcache, stash-cache, stash-origin]
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load cached base image
uses: actions/cache@v3
with:
path: /tmp/.base-buildx-cache
key: base-${{ matrix.osg_series.name }}-${{ matrix.repo }}-buildx-${{ github.sha }}-${{ github.run_id }}
- name: Cache child image
uses: actions/cache@v3
with:
path: /tmp/.${{ matrix.image }}-buildx-cache
key: ${{ matrix.image}}-${{matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
target: ${{ matrix.image }}
cache-from: type=local,src=/tmp/.base-buildx-cache
cache-to: type=local,dest=/tmp/.${{ matrix.image }}-buildx-cache,mode=max
test-stash-cache:
name: Test Stash Cache and Origin
needs: [xcache-image-builds]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.repo == 'development' }}
strategy:
fail-fast: False
matrix:
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
steps:
- uses: actions/checkout@v3
- name: Load stash-cache build cache
uses: actions/cache@v3
with:
path: /tmp/.stash-cache-buildx-cache
key: stash-cache-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Load stash-origin build cache
uses: actions/cache@v3
with:
path: /tmp/.stash-origin-buildx-cache
key: stash-origin-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Load stash-cache image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
load: True # allow access to built images through the Docker CLI
tags: stash-cache:latest
target: stash-cache
cache-from: type=local,src=/tmp/.stash-cache-buildx-cache
- name: Load stash-origin image
uses: docker/build-push-action@v4
with:
context: .
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
load: True # allow access to built images through the Docker CLI
tags: stash-origin:latest
target: stash-origin
cache-from: type=local,src=/tmp/.stash-origin-buildx-cache
- run: ./tests/test_stashcache_origin.sh "stash-origin:latest"
- run: ./tests/test_stashcache.sh "stash-cache:latest"
make-date-tag:
runs-on: ubuntu-latest
if: contains(fromJson('["push", "repository_dispatch", "workflow_dispatch"]'), github.event_name) && startsWith(github.repository, 'opensciencegrid/')
outputs:
dtag: ${{ steps.mkdatetag.outputs.dtag }}
steps:
- name: make date tag
id: mkdatetag
run: echo "dtag=$(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT
push-images:
name: Push ${{ matrix.image }}:${{ matrix.osg_series.name }}-${{ matrix.repo }} image
if: contains(fromJson('["push", "repository_dispatch", "workflow_dispatch"]'), github.event_name) && startsWith(github.repository, 'opensciencegrid/')
strategy:
fail-fast: False
matrix:
image: [atlas-xcache, cms-xcache, stash-cache, stash-origin, xcache]
repo: ['development', 'testing', 'release']
osg_series:
- name: '23'
os: 'el9'
needs: [make-date-tag, test-stash-cache]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load cached child image
uses: actions/cache@v3
with:
path: /tmp/.${{ matrix.image }}-buildx-cache
key: ${{ matrix.image}}-${{ matrix.osg_series.name }}-${{ matrix.repo}}-build-${{ github.sha}}-${{ github.run_id }}
- name: Generate tag list
id: generate-tag-list
env:
REPO: ${{ matrix.repo }}
SERIES: ${{ matrix.osg_series.name }}
IMAGE: ${{ matrix.image }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
docker_repo=opensciencegrid/$IMAGE
tag_list=()
for registry in hub.opensciencegrid.org docker.io; do
for image_tag in "$SERIES-$REPO" "$SERIES-$REPO-$TIMESTAMP"; do
tag_list+=("$registry/$docker_repo":"$image_tag")
done
done
# This causes the tag_list array to be comma-separated below,
# which is required for build-push-action
IFS=,
echo "taglist=${tag_list[*]}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to OSG Harbor
uses: docker/[email protected]
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Build ${{ matrix.image}} image
uses: docker/build-push-action@v4
with:
context: .
push: True
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
target: ${{ matrix.image }}
cache-from: type=local,src=/tmp/.${{ matrix.image }}-buildx-cache