Skip to content

Commit a2c2fd5

Browse files
committed
fix: abort cron job if git repo prep fails
1 parent 3de0c01 commit a2c2fd5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
### CLI
66
- new command unipipe generate terraform-runner-hello-world will generate a sample catalog + terraform files for use with unipipe terraform command
77

8+
### Terraform Runner
9+
- Improve runner script robustness
10+
- Abort cron job if Git repo setup fails
11+
812
## v1.7.1
913

1014
### Terraform Runner

terraform-runner/run-unipipe-terraform.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
#! /bin/bash
1+
#!/usr/bin/env bash
2+
# Exit on all errors and undefined vars
3+
set -o errexit
4+
set -o errtrace
5+
set -o pipefail
6+
set -o nounset
27

38
REPO_NAME=instances-repo
49
REPO_DIR=~/unipipe/$REPO_NAME
5-
if [ ! -f "$REPO_DIR" ]; then
6-
cat >~/.ssh/id_rsa <<< "${GIT_SSH_KEY}"
10+
if [[ ! -d "$REPO_DIR" ]]; then
11+
cat > ~/.ssh/id_rsa <<< "${GIT_SSH_KEY}"
712
chmod 700 ~/.ssh
813
chmod 600 ~/.ssh/id_rsa
914
cd ~/unipipe
10-
git config --global user.email $GIT_USER_EMAIL
11-
git config --global user.name $GIT_USER_NAME
12-
git clone $GIT_REMOTE $REPO_NAME
15+
git config --global user.email "$GIT_USER_EMAIL"
16+
git config --global user.name "$GIT_USER_NAME"
17+
git clone "$GIT_REMOTE" "$REPO_NAME"
1318
fi
1419

1520
cd $REPO_DIR

0 commit comments

Comments
 (0)