From 8f0b3edabb2a4ee7fe1fcc600329827568b67c6d Mon Sep 17 00:00:00 2001 From: Graham Krizek Date: Sun, 9 Dec 2018 23:32:14 -0600 Subject: [PATCH] Update git example --- examples/example-git.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) mode change 100644 => 100755 examples/example-git.sh diff --git a/examples/example-git.sh b/examples/example-git.sh old mode 100644 new mode 100755 index 194edc38..a004dcc4 --- a/examples/example-git.sh +++ b/examples/example-git.sh @@ -5,17 +5,19 @@ handler () { EVENT_DATA=$1 echo $EVENT_DATA - REPO=$(echo $EVENT_DATA | jq ."repository") + REPO=$(echo $EVENT_DATA | jq -r ."repository") + OWNER=$(echo $EVENT_DATA | jq -r ."owner") + BUCKET=$(echo $EVENT_DATA | jq -r ."bucket") mkdir -p /tmp/.ssh - aws s3 cp s3://bucket/id_rsa /tmp/.ssh/id_rsa + aws s3 cp s3://$BUCKET/id_rsa /tmp/.ssh/id_rsa chmod 400 /tmp/.ssh/id_rsa eval `ssh-agent -s` export GIT_SSH="/tmp" export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/tmp/.ssh/known_hosts -i /tmp/.ssh/id_rsa" ssh-add /tmp/.ssh/id_rsa 2>&1 ssh-keyscan github.com >> /tmp/.ssh/known_hosts 2>&1 - git clone ssh://git@github.com/owner/repo.git /tmp/repo 2>&1 - ls -al /tmp/repo + git clone ssh://git@github.com/$OWNER/$REPO.git /tmp/$REPO 2>&1 + ls -al /tmp/$REPO echo "Successfully cloned repository" >&2 } \ No newline at end of file