forked from cssu/cssu.ca-old
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_pages.sh
More file actions
executable file
·40 lines (32 loc) · 1.21 KB
/
Copy pathdeploy_pages.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.21 KB
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
#!/usr/bin/env bash
# Strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
TARGET_REPO="git@github.com:cssu/cssu.ca.git"
SHA="$(git rev-parse --verify HEAD)"
# Decrypt deploy key
echo "Decrypting deploy key to .travis/deploy_key..."
openssl aes-256-cbc -K $encrypted_d7c771f4f1c5_key -iv $encrypted_d7c771f4f1c5_iv -in .travis/deploy_key.enc -out .travis/deploy_key -d
# Add deploy key to SSH agent
echo "Adding deploy key .travis/deploy_key to ssh-agent..."
eval "$(ssh-agent -s)"
chmod 600 .travis/deploy_key
ssh-add .travis/deploy_key
# Clone the existing gh-pages for this repo into out/
git clone "$TARGET_REPO" gh_pages_repo
cd gh_pages_repo
git checkout "$TARGET_BRANCH"
cd ..
echo Clean out existing contents and copy in Jekyll site
rsync -av --exclude ".git" --delete _site/ gh_pages_repo/
# Now let's go have some fun with the cloned repo
cd gh_pages_repo
git config user.name "Travis CI"
# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add -A .
git commit -m "Deploy to GitHub Pages: ${SHA}"
# Now that we're all set up, we can push.
git push origin "$TARGET_BRANCH"