-
Notifications
You must be signed in to change notification settings - Fork 19
191 lines (172 loc) · 6.34 KB
/
release-series-builds.yml
File metadata and controls
191 lines (172 loc) · 6.34 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
---
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: '24'
os: 'el9'
osg_series:
- name: '25'
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/setup-buildx-action@v2.7.0
- 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]
repo: ['development', 'testing', 'release']
osg_series:
- name: '24'
os: 'el9'
- name: '25'
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/setup-buildx-action@v2.7.0
- 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
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, xcache]
repo: ['development', 'testing', 'release']
osg_series:
- name: '24'
os: 'el9'
organization: 'osg-htc'
- name: '25'
os: 'el9'
organization: 'osg-htc'
needs: [make-date-tag, xcache-image-builds]
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 }}
ORGANIZATION: ${{ matrix.osg_series.organization }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
docker_repo=$ORGANIZATION/$IMAGE
tag_list=()
for registry in hub.opensciencegrid.org docker.io; do
# osg-htc org doesn't exist in docker.io
if [[ "$registry" == "docker.io" && "$ORGANIZATION" == "osg-htc" ]]; then
continue
fi
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/setup-buildx-action@v2.7.0
- name: Log in to Docker Hub
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to OSG Harbor
uses: docker/login-action@v2.2.0
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