Skip to content

Commit

Permalink
Merge pull request #7 from rackspace-infrastructure-automation/jp/ssh…
Browse files Browse the repository at this point in the history
…-spike

fetch origin from github.com forcing regular ssh keys
  • Loading branch information
jpbochi authored Oct 2, 2018
2 parents 4fdc90c + f972705 commit 2c7f575
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
7 changes: 3 additions & 4 deletions repository_template/bin/apply.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

set -e
#!/usr/bin/env sh
set -eu

. $(dirname $(realpath $0))/variables.sh

Expand All @@ -26,4 +25,4 @@ done
# escrows applied revision
REVISION=${CIRCLE_SHA1:-$(git rev-parse HEAD)}
echo $REVISION > tf-applied-revision.sha
aws s3 cp ./tf-applied-revision.sha "s3://${TF_STATE_BUCKET}/"
aws s3 cp ./tf-applied-revision.sha "s3://${TF_STATE_BUCKET}/"
13 changes: 4 additions & 9 deletions repository_template/bin/check_old.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh
#!/usr/bin/env sh
set -eu

# be sure branch is up to date
git fetch origin

# in the last hundred commits, is one of the parents in the current master?
if ! (git log --pretty=format:'%H' -n 100 | grep -q "$(git rev-parse remotes/origin/master)"); then
echo >&2 'Your branch is not up to date. Exiting.'
exit 1
fi
echo >&2 'Calling check_old.sh explicitly is not required anymore.'
echo >&2 'Feel free to remove it from your build pipeline.'
5 changes: 2 additions & 3 deletions repository_template/bin/lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

set -e
#!/usr/bin/env sh
set -eu

. $(dirname $(realpath $0))/variables.sh

Expand Down
5 changes: 2 additions & 3 deletions repository_template/bin/plan.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

set -e
#!/usr/bin/env sh
set -eu

. $(dirname $(realpath $0))/variables.sh

Expand Down
25 changes: 23 additions & 2 deletions repository_template/bin/variables.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#!/bin/sh
#!/usr/bin/env sh
set -eu

set -e
check_old() {
local fake_hostname='github.com.original.invalid'
# avoid overridden ssh config for github.com
if ! (ssh -G $fake_hostname | grep -q '^hostname github.com$'); then
echo "Host ${fake_hostname}" >> ~/.ssh/config
echo ' HostName github.com' >> ~/.ssh/config
fi

# be sure branch is up to date
git fetch --quiet --depth 100 $(git config --get remote.origin.url | sed "s/[email protected]:/git@${fake_hostname}:/")

# in the last hundred commits, is one of the parents in the current master?
if ! (git log --pretty=format:'%H' -n 100 | grep -q "$(git rev-parse remotes/origin/master)"); then
echo >&2 'Your branch is not up to date. Exiting...'
exit 1
else
echo 'Your branch is up to date. Proceeding...'
fi
}

check_old

# standard paths
MASTER_REF=$(git rev-parse remotes/origin/master)
Expand Down

0 comments on commit 2c7f575

Please sign in to comment.