forked from reichlab/covid19-forecast-hub-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·62 lines (49 loc) · 1.55 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# If a command fails then the deploy stops
set -e
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//[email protected]:}
HEAD_HASH=`git rev-parse --verify HEAD` # latest commit hash
HEAD_HASH=${HEAD_HASH: -7} # get the last 7 characters of hash
# system requirements
sudo apt-get update
sudo apt-get install -y ruby ruby-dev gem
# python requirements
pip install pipenv
pipenv install
# ruby requirements
bundle install
# generation of community file
if [ "$1" != "skip_gen" ]; then
printf "Generating community file"
pipenv run python3 update-community.py
else
printf "Skipping community file generation"
fi
# weekly reports/evaluation reports
pipenv run python3 update-reports.py
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
# remove old site and fetch clean repo
# might be useful for a local build, likely not impacting CI Actions
rm -rf ./docs
git fetch
# Build the project into a local untracked "docs" directory on the master branch
bundle exec jekyll build -d docs
if [ "$CI" = "true" ]; then
git config user.name "GitHub Action"
git config user.email "[email protected]"
fi
# Push source and build repos
if [ "$1" != "no_push" ] && [ "$2" != "no_push" ]
then
printf "Pushing to GitHub"
# switch to netlify branch, bringing along untracked "docs" directory
git switch netlify
# Commit changes.
msg="Auto deploy commit ${HEAD_HASH} to Netlify at ${date}"
(cd docs; git add .)
(cd docs; git diff-index --quiet HEAD || git commit -am "$msg")
git push origin netlify
else
printf "Skipping push to GitHub"
fi