aboutsummaryrefslogtreecommitdiff
path: root/common/git-clone.sh
diff options
context:
space:
mode:
Diffstat (limited to 'common/git-clone.sh')
-rw-r--r--common/git-clone.sh18
1 files changed, 18 insertions, 0 deletions
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