forked from json-e/json-e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·43 lines (32 loc) · 1.28 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -o errexit -o nounset
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
BUILD_DIR="docs"
if [ "$GITHUB_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Non-$SOURCE_BRANCH branch build; skipping deployment."
exit 0
fi
SHA=`git rev-parse --short HEAD`
GITHUB_PROJECT=$(echo $GITHUB_BASE_REPO_URL | sed 's/^https:\/\/github.com\///' | sed 's/.git$//')
SECRETS_URL="taskcluster/secrets/v1/secret/repo:github.com/$GITHUB_PROJECT"
echo "Using project: $GITHUB_PROJECT"
echo "Using secrets: $SECRETS_URL"
mkdir ~/.ssh
curl "${SECRETS_URL}" | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["githubPubKey"]' >> ~/.ssh/known_hosts
BASE64_DEPLOY_KEY=$(curl ${SECRETS_URL} | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["base64DeployKey"]')
echo "$BASE64_DEPLOY_KEY" | base64 -d > /deploy_key
chmod 600 /deploy_key
eval `ssh-agent -s`
ssh-add /deploy_key
cd $BUILD_DIR
git init
git config user.name "Taskcluster Github"
git config user.email "[email protected]"
git remote add upstream "[email protected]:$GITHUB_PROJECT.git"
git fetch upstream
git reset "upstream/$TARGET_BRANCH"
touch .
git add -A .
git commit --allow-empty -m "Rebuilding $TARGET_BRANCH from $SHA"
git push -q upstream "HEAD:$TARGET_BRANCH"