aboutsummaryrefslogtreecommitdiff
path: root/ci/ci.sh
blob: fc523d8f54cb01d4f8e0ad3ff083985b807d50d0 (plain)
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
#!/bin/bash
set -evuo pipefail

# Use podman if available, otherwise use docker.
# Fails if neither is found in PATH
OCI_RUNTIME=$(which podman || which docker)
REPO_NAME=$(basename "${PWD}")
JOB_NAME="${1}"
JOB_CONTAINER=$((grep CONTAINER_NAME ci/jobs/${JOB_NAME}/config.ini | cut -d' ' -f 3) || echo "${REPO_NAME}")

echo "${JOB_CONTAINER}"

if [ "${JOB_CONTAINER}" = "${REPO_NAME}" ] ; then
	"${OCI_RUNTIME}" build \
		-t "${JOB_CONTAINER}" \
		-f ci/Containerfile .
fi

"${OCI_RUNTIME}" run \
	--rm \
	-ti \
	--volume "${PWD}":/workdir \
	--workdir /workdir \
	"${JOB_CONTAINER}" \
	ci/jobs/"${JOB_NAME}"/job.sh

top_dir=$(dirname "${BASH_SOURCE[0]}")

#"${top_dir}"/build.sh