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 ++++++++++++++++++ eventline/ev-scripts-deploy.yaml | 15 +++++++++++++-- 5 files changed, 56 insertions(+), 17 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 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 diff --git a/eventline/ev-scripts-deploy.yaml b/eventline/ev-scripts-deploy.yaml index e01c567..21fb320 100644 --- a/eventline/ev-scripts-deploy.yaml +++ b/eventline/ev-scripts-deploy.yaml @@ -1,7 +1,14 @@ name: "ev-scripts-deploy" steps: - - script: - path: "../common/make-run.sh" + - label: git clone + script: + path: "../common/git-clone.sh" + - label: make run + script: + path: "../common/make.sh" + - label: clean + script: + path: "../common/clean.sh" identities: - eventline-self parameters: @@ -9,6 +16,10 @@ parameters: type: string default: "ev-scripts-deploy" environment: NAME +- name: target + type: string + default: "run" + environment: TARGET - name: url type: string default: "https://git.adyxax.org/adyxax/ev-scripts" -- cgit v1.2.3