-
Notifications
You must be signed in to change notification settings - Fork 13
228 lines (207 loc) · 8.03 KB
/
workspaces_build.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
# SPDX-FileCopyrightText: 2020 Fermi Research Alliance, LLC
# SPDX-License-Identifier: Apache-2.0
# This workflow can be triggered w/ a dispatch event, e.g.:
# curl -X POST -H "Authorization: token $(cat ../token_file)" \
# -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" \
# https://api.github.com/repos/glideinwms/containers/dispatches \
# -d '{"event_type":"workspaces-build", "client_payload": {"label":"latest", "date_tag":true}}'
# A valid GitHub token must be saved in the file (so that is presented in the authorization)
# otherwise a misleading "Not Found" message is returned. No reply is provided for successful posts.
# The client_payload label and date_tag are optional
# label is used as Docker Hub label instead of "latest"
# if date_tag id true a date tag is added to the Docker Hub label (+%Y%m%d-%H%M)
# -X POST is also optional
#
# You can use also the gh cli:
# jq -n '{"event_type":"workspaces-build", "client_payload": {"label":"latest", "date_tag":true}}' | \
# gh api repos/glideinwms/containers/dispatches --input -
# TODO: reduce run times, these allow filters at the job level:
# https://github.com/tj-actions/changed-files
# https://github.com/dorny/paths-filter
# TODO: single wf also sl7 on-pull setting variable? DH_OS env? image name, tag name, platform list
name: Build and Push Workspaces
on:
push:
branches: [main ]
paths: ['workspaces/**']
pull_request:
branches: [main ]
paths: ['workspaces/**']
workflow_dispatch:
inputs:
date_tag:
description: 'True to add the date to the image tag'
required: true
default: false
type: boolean
label:
description: 'Label to use as image tag'
required: false
type: string
sl7_build:
description: 'True if building for CentOS7/SL7'
required: true
default: false
type: boolean
repository_dispatch:
types:
- workspaces-build
env:
DH_LABEL: latest
DH_PREFIX: ''
DH_PLATFORMS: linux/amd64,linux/arm64
OSG_VERSION: NO
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set env date and hash
id: setenv_vars
shell: bash
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "GITHUB_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
- name: set label branch
id: setlabel_branch
shell: bash
run: |
if [[ ${GITHUB_REF##*/} = osg* ]]; then
echo "DH_LABEL=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "OSG_VERISON=${GITHUB_REF##*/}" >> $GITHUB_ENV
fi
- name: set label from parameter
id: setlabel_parameter
continue-on-error: true
if: ${{ github.event.client_payload.label }}
run: |
echo "DH_LABEL=${{ github.event.client_payload.label }}" >> $GITHUB_ENV
- name: set label from inputs
id: setlabel_inputs
continue-on-error: true
if: ${{ inputs.label }}
run: |
echo "DH_LABEL=${{ inputs.label }}" >> $GITHUB_ENV
- name: add date tag
continue-on-error: true
if: ${{ github.event.client_payload.date_tag || inputs.date_tag }}
run: |
echo "DH_LABEL=$DH_LABEL-$(date +%Y%m%d-%H%M)" >> $GITHUB_ENV
- name: set variables for SL7 build from inputs
id: setsl7_inputs
continue-on-error: true
if: ${{ inputs.sl7_build }}
run: |
echo "DH_PREFIX=sl7_" >> $GITHUB_ENV
echo "DH_PLATFORMS=linux/amd64" >> $GITHUB_ENV
- uses: satackey/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
with:
key: gwms-docker-cache-{hash}
restore-keys: |
gwms-docker-cache-
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push gwms-workspace
id: docker_build_gwms_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/gwms-workspace/Dockerfile
tags: glideinwms/gwms-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}
#cache-from: type=gha
#cache-to: type=gha,mode=max
- name: Build and push build-workspace
id: docker_build_build_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/build-workspace/Dockerfile
tags: glideinwms/build-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push ce-workspace
id: docker_build_ce_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/ce-workspace/Dockerfile
tags: glideinwms/ce-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push factory-workspace
id: docker_build_factory_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/factory-workspace/Dockerfile
tags: glideinwms/factory-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push frontend-workspace
id: docker_build_frontend_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/frontend-workspace/Dockerfile
tags: glideinwms/frontend-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push testbed-workspace
id: docker_build_testbed_workspace
continue-on-error: true
if: ${{ ! inputs.sl7_build }}
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/testbed-workspace/Dockerfile
tags: glideinwms/testbed-workspace:${{env.DH_PREFIX}}${{env.DH_LABEL}}
build-args: |
BUILD_SHA=${{env.GITHUB_SHA}}
BUILD_HASH=${{env.GITHUB_HASH}}
BUILD_REF=${{env.GITHUB_REF}}
BUILD_DATE=${{env.BUILD_DATE}}
GWMS_VERSION=${{env.DH_PREFIX}}${{env.DH_LABEL}}