-
Notifications
You must be signed in to change notification settings - Fork 13
/
action.yml
358 lines (301 loc) · 14.4 KB
/
action.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: "docker-ros"
description: "docker-ros automatically builds development and deployment Docker images for your ROS-based repositories."
branding:
color: blue
icon: package
inputs:
target:
description: "Target stage of Dockerfile (comma-separated list) [dev|run]"
default: run
platform:
description: "Target platform architecture (comma-separated list) [amd64|arm64|...]"
base-image:
description: "Base image name:tag"
required: true
command:
description: "Launch command of run image (required if target=run)"
image-name:
description: "Image name of run image"
default: ghcr.io/${{ github.repository }}
image-tag:
description: "Image tag of run image"
default: latest
dev-image-name:
description: "Image name of dev image"
default: ghcr.io/${{ github.repository }}
dev-image-tag:
description: "Image tag of dev image"
slim-image-name:
description: "Image name of slim run image"
default: ghcr.io/${{ github.repository }}
slim-image-tag:
description: "Image tag of slim run image"
build-context:
description: "Build context of Docker build process"
default: ${{ github.workspace }}
registry:
description: "Docker registry to push images to"
default: ghcr.io
registry-user:
description: "Docker registry username"
default: ${{ github.actor }}
registry-password:
description: "Docker registry password"
default: ${{ github.token }}
rmw-implementation:
description: "RMW implementation to use (only for ROS 2)"
default: rmw_cyclonedds_cpp
ros-distro:
description: "ROS Distro (required if ROS is not installed in `base-image`)"
disable-ros-installation:
description: "Disable automatic installation of `ros-$ROS_DISTRO-ros-core` package, e.g., if ROS is already installed in `base-image` and package is not available for the OS"
default: false
git-https-server:
description: "Server URL (without protocol) for cloning private Git repositories via HTTPS"
default: "github.com"
git-https-user:
description: "Username for cloning private Git repositories via HTTPS"
default: ${{ github.actor }}
git-https-password:
description: "Password for cloning private Git repositories via HTTPS"
default: ${{ github.token }}
git-ssh-private-key:
description: "SSH private key for cloning private Git repositories via SSH"
git-ssh-known-host-keys:
description: "Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`)"
additional-debs-file:
description: "Relative filepath to file containing additional apt deb packages to install"
default: docker/additional-debs.txt
enable-recursive-additional-debs:
description: "Enable recursive discovery of files named `additional-debs-file`"
default: false
additional-files-dir:
description: "Relative path to directory containing additional files to copy into image"
default: docker/additional-files
additional-pip-file:
description: "Relative filepath to file containing additional pip packages to install"
default: docker/additional-pip-requirements.txt
enable-recursive-additional-pip:
description: "Enable recursive discovery of files named `additional-pip-file`"
default: false
blacklisted-packages-file:
description: "Relative filepath to file containing blacklisted packages to remove from workspace"
default: docker/blacklisted-packages.txt
enable-recursive-blacklisted-packages:
description: "Enable recursive discovery of files named `blacklisted-packages-file`"
default: false
custom-script-file:
description: "Relative filepath to script containing custom installation commands"
default: docker/custom.sh
enable-recursive-custom-script:
description: "Enable recursive discovery of files named `custom-script-file`"
default: false
enable-industrial-ci:
description: "Enable industrial_ci"
default: false
enable-slim:
description: "Enable an extra slimmed run image via slim (only if run stage is targeted)"
default: true
slim-build-args:
description: "Arguments to `slim build` (except for `--target` and `--tag`)"
default: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false'
enable-singlearch-push:
description: "Enable push of single arch images with [-amd64|-arm64] postfix"
default: false
enable-push-as-latest:
description: "Push images with tag `latest`/`latest-dev` in addition to the configured image names"
default: false
enable-checkout:
description: "Enable checkout action to (re-)download your repository prior to running the pipeline"
default: true
enable-checkout-submodules:
description: "Enable submodules for the checkout action (false|true|recursive)"
default: recursive
enable-checkout-lfs:
description: "Enable Git LFS support for the checkout action"
default: true
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v3
if: ${{ inputs.enable-checkout == 'true' }}
with:
submodules: ${{ inputs.enable-checkout-submodules }}
lfs: ${{ inputs.enable-checkout-lfs }}
- name: Set up docker-ros
shell: bash
working-directory: ${{ inputs.build-context }}
run: |
if ! [[ -d "docker/docker-ros" ]]; then
mkdir -p docker
cp -r ${GITHUB_ACTION_PATH} docker/docker-ros
fi
- name: Prepare setup of QEMU
id: prepare-setup-of-qemu
shell: bash
run: echo "RUNNER_ARCH=$(dpkg --print-architecture)" >> $GITHUB_OUTPUT
- name: Set up QEMU
if: ${{ steps.prepare-setup-of-qemu.outputs.RUNNER_ARCH != inputs.platform }}
uses: docker/setup-qemu-action@v2
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry-user }}
password: ${{ inputs.registry-password }}
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Enforce lower-case image name
id: image-name
uses: ASzc/change-string-case-action@v6
with:
string: ${{ inputs.image-name }}
- name: Enforce lower-case dev image name
id: dev-image-name
uses: ASzc/change-string-case-action@v6
with:
string: ${{ inputs.dev-image-name }}
- name: Enforce lower-case slim image name
id: slim-image-name
uses: ASzc/change-string-case-action@v6
with:
string: ${{ inputs.slim-image-name }}
- name: Build images
id: build-images
shell: bash
working-directory: ${{ inputs.build-context }}
run: docker/docker-ros/scripts/ci.sh
env:
PLATFORM: ${{ inputs.platform }}
TARGET: ${{ inputs.target }}
BASE_IMAGE: ${{ inputs.base-image }}
COMMAND: ${{ inputs.command }}
IMAGE_NAME: ${{ steps.image-name.outputs.lowercase }}
IMAGE_TAG: ${{ inputs.image-tag }}
DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }}
DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }}
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }}
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }}
GIT_HTTPS_SERVER: ${{ inputs.git-https-server }}
GIT_HTTPS_USER: ${{ inputs.git-https-user }}
GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }}
GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }}
GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }}
ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }}
ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }}
ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }}
ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }}
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
BLACKLISTED_PACKAGES_FILE: ${{ inputs.blacklisted-packages-file }}
ENABLE_RECURSIVE_BLACKLISTED_PACKAGES: ${{ inputs.enable-recursive-blacklisted-packages }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
VCS_IMPORT_FILE: ${{ inputs.vcs-import-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}
- name: Set up industrial_ci
if: ${{ inputs.enable-industrial-ci == 'true' }}
shell: bash
run: test -f ${{ inputs.build-context }}/.repos || echo "repositories:" > ${{ inputs.build-context }}/.repos
- name: Run industrial_ci
if: ${{ inputs.enable-industrial-ci == 'true' }}
uses: ros-industrial/industrial_ci@master
env:
UPSTREAM_WORKSPACE: ${{ inputs.build-context }}/.repos
TARGET_WORKSPACE: ${{ inputs.build-context }}
ADDITIONAL_DEBS: git
AFTER_INIT_EMBED: '[[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]] && export UNDERLAY="/opt/ws_rmw_zenoh/install" ; [[ -n ${{ inputs.git-https-server }} ]] && git config --global url.https://${{ inputs.git-https-user }}:${{ inputs.git-https-password }}@${{ inputs.git-https-server }}.insteadOf https://${{ inputs.git-https-server }}'
SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }}
SSH_SERVER_HOSTKEYS: ${{ inputs.git-ssh-known-host-keys }}
DOCKER_RUN_OPTS: -u root:root
DOCKER_IMAGE: ${{ steps.build-images.outputs.INDUSTRIAL_CI_IMAGE }}
DOCKER_PULL: false
- name: Slugify ref name
id: slugify-ref-name
uses: gacts/github-slug@v1
with:
to-slug: ${{ github.ref_name }}
- name: Push images
shell: bash
working-directory: ${{ inputs.build-context }}
run: docker/docker-ros/scripts/ci.sh
env:
PLATFORM: ${{ inputs.platform }}
TARGET: ${{ inputs.target }}
BASE_IMAGE: ${{ inputs.base-image }}
COMMAND: ${{ inputs.command }}
IMAGE_NAME: ${{ steps.image-name.outputs.lowercase }}
IMAGE_TAG: ${{ inputs.image-tag }}
DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }}
DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }}
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: ${{ inputs.slim-image-tag }}
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }}
GIT_HTTPS_SERVER: ${{ inputs.git-https-server }}
GIT_HTTPS_USER: ${{ inputs.git-https-user }}
GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }}
GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }}
GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }}
ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }}
ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }}
ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }}
ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }}
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
BLACKLISTED_PACKAGES_FILE: ${{ inputs.blacklisted-packages-file }}
ENABLE_RECURSIVE_BLACKLISTED_PACKAGES: ${{ inputs.enable-recursive-blacklisted-packages }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
VCS_IMPORT_FILE: ${{ inputs.vcs-import-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}
_ENABLE_IMAGE_PUSH: true
_IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }}
- name: Push images (as latest)
if: ${{ inputs.enable-push-as-latest == 'true' }}
shell: bash
working-directory: ${{ inputs.build-context }}
run: docker/docker-ros/scripts/ci.sh
env:
PLATFORM: ${{ inputs.platform }}
TARGET: ${{ inputs.target }}
BASE_IMAGE: ${{ inputs.base-image }}
COMMAND: ${{ inputs.command }}
IMAGE_NAME: ${{ steps.image-name.outputs.lowercase }}
IMAGE_TAG: latest
DEV_IMAGE_NAME: ${{ steps.dev-image-name.outputs.lowercase }}
DEV_IMAGE_TAG: latest-dev
SLIM_IMAGE_NAME: ${{ steps.slim-image-name.outputs.lowercase }}
SLIM_IMAGE_TAG: latest-slim
ENABLE_SLIM: ${{ inputs.enable-slim }}
SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }}
ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }}
RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }}
ROS_DISTRO: ${{ inputs.ros-distro }}
DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }}
GIT_HTTPS_SERVER: ${{ inputs.git-https-server }}
GIT_HTTPS_USER: ${{ inputs.git-https-user }}
GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }}
GIT_SSH_PRIVATE_KEY: ${{ inputs.git-ssh-private-key }}
GIT_SSH_KNOWN_HOST_KEYS: ${{ inputs.git-ssh-known-host-keys }}
ADDITIONAL_DEBS_FILE: ${{ inputs.additional-debs-file }}
ENABLE_RECURSIVE_ADDITIONAL_DEBS: ${{ inputs.enable-recursive-additional-debs }}
ADDITIONAL_FILES_DIR: ${{ inputs.additional-files-dir }}
ADDITIONAL_PIP_FILE: ${{ inputs.additional-pip-file }}
ENABLE_RECURSIVE_ADDITIONAL_PIP: ${{ inputs.enable-recursive-additional-pip }}
BLACKLISTED_PACKAGES_FILE: ${{ inputs.blacklisted-packages-file }}
ENABLE_RECURSIVE_BLACKLISTED_PACKAGES: ${{ inputs.enable-recursive-blacklisted-packages }}
CUSTOM_SCRIPT_FILE: ${{ inputs.custom-script-file }}
ENABLE_RECURSIVE_CUSTOM_SCRIPT: ${{ inputs.enable-recursive-custom-script }}
VCS_IMPORT_FILE: ${{ inputs.vcs-import-file }}
ENABLE_RECURSIVE_VCS_IMPORT: ${{ inputs.enable-recursive-vcs-import }}
_ENABLE_IMAGE_PUSH: true
_IMAGE_POSTFIX: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('_{0}_ci', steps.slugify-ref-name.outputs.slug) || '' }}