From 79b46e27d6dd054aac8c281ac6897a65d9549f9e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 6 Sep 2022 19:55:22 +0200 Subject: Split the deploy script in distinct tasks --- common/clean.sh | 7 +++++++ common/git-clone.sh | 18 ++++++++++++++++++ common/make-run.sh | 15 --------------- common/make.sh | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 common/clean.sh create mode 100644 common/git-clone.sh delete mode 100644 common/make-run.sh create mode 100644 common/make.sh (limited to 'common') diff --git a/common/clean.sh b/common/clean.sh new file mode 100644 index 0000000..40ec605 --- /dev/null +++ b/common/clean.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Input environment: +# - NAME: a name for the script/tasks + +rm -rf "/tmp/${NAME}" diff --git a/common/git-clone.sh b/common/git-clone.sh new file mode 100644 index 0000000..1a1a89c --- /dev/null +++ b/common/git-clone.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Input environment: +# - NAME: a name for the script/tasks +# - URL: the url of the repository to clone + +WORKDIR="/tmp/${NAME}" + +cleanup() { + rm -rf "${WORKDIR}" +} + +trap cleanup EXIT + +git clone -q "${URL}" "${WORKDIR}" + +trap - EXIT diff --git a/common/make-run.sh b/common/make-run.sh deleted file mode 100644 index 8c719b2..0000000 --- a/common/make-run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -WORKDIR="/tmp/${NAME}" - -cleanup() { - cd / - rm -rf "${WORKDIR}" -} - -trap cleanup EXIT - -git clone -q "${URL}" "${WORKDIR}" -cd "${WORKDIR}" -make run diff --git a/common/make.sh b/common/make.sh new file mode 100644 index 0000000..c3b0912 --- /dev/null +++ b/common/make.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Input environment: +# - NAME: a name for the script/tasks +# - TARGET: the Makefile target to run + +WORKDIR="/tmp/${NAME}" + +cleanup() { + rm -rf "${WORKDIR}" +} + +trap cleanup EXIT + +(cd "${WORKDIR}" && make "${TARGET}") + +trap - EXIT -- cgit v1.2.3