This repository was archived by the owner on Jan 29, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
63 lines (52 loc) · 1.95 KB
/
run.sh
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
#!/bin/bash
set -ex
# clean any prexisting variable values
unset BASEIMAGE_ARCH CLEANUP_ARCH README_SYNC SHELLCHECK_ARCH
# test if node is for readme-sync
if [[ "${NODE_LABELS}" == *"README"* ]]; then
README_SYNC="true"
fi
# set arch for shellcheck readme-sync and cleanup based on node labels
if [[ "${NODE_LABELS}" == *"X86"* ]]; then
BASEIMAGE_ARCH="x86-64"
README_SYNC_ARCH=""
SHELLCHECK_ARCH=""
CLEANUP_ARCH=""
elif [[ "${NODE_LABELS}" == *"ARM"* ]]; then
SHELLCHECK_ARCH="-armhf"
README_SYNC_ARCH="-armhf"
if [[ "${NODE_LABELS}" == *"ARM64"* ]]; then
BASEIMAGE_ARCH="arm64"
elif [[ "${NODE_LABELS}" == *"ARMHF"* ]]; then
BASEIMAGE_ARCH="armhf"
fi
CLEANUP_ARCH="-${BASEIMAGE_ARCH}"
fi
# pull docker images reading from docker-gc excludes file, ignoring readme-sync and shellcheck
while read -r excludes_file
do
if [[ -z "${excludes_file}" || "${excludes_file}" == *"readme-sync"* \
|| "${excludes_file}" == *"shellcheck"* ]]; then
:
elif [[ "${excludes_file}" == *"$BASEIMAGE_ARCH"* && "$BASEIMAGE_ARCH" == "arm64" ]]; then
docker pull "${excludes_file}"
elif [[ ("${excludes_file}" == *"$BASEIMAGE_ARCH"* || "${excludes_file}" == *"arm32"*) && "$BASEIMAGE_ARCH" == "armhf" \
&& "${NODE_LABELS}" != *"README"* ]]; then
docker pull "${excludes_file}"
elif [[ "${excludes_file}" != *"armhf"* && "${excludes_file}" != *"arm32"* && "${excludes_file}" != *"arm64"* \
&& "$BASEIMAGE_ARCH" == "x86-64" ]]; then
docker pull "${excludes_file}"
fi
done < "${WORKSPACE}"/exclude_list
# pull shellcheck image or readme-sync image dependant on node
if [[ "${README_SYNC}" == "true" ]]; then \
docker pull lsiodev/readme-sync"${README_SYNC_ARCH}"
else
docker pull lsiodev/shellcheck"${SHELLCHECK_ARCH}"
fi
# pull cleanup image
docker pull lsiodev/docker-gc"${CLEANUP_ARCH}"
# run docker gc
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "${WORKSPACE}"/exclude_list:/etc/docker-gc-exclude lsiodev/docker-gc"${CLEANUP_ARCH}" || true