/
push-lessons.sh
35 lines (29 loc) · 970 Bytes
/
push-lessons.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
#!/bin/bash
# Thanks to willprice: https://gist.github.com/willprice/e07efd73fb7f13f917ea
setup_git() {
git config --global user.email "bot@bits-and-bots.github.io"
git config --global user.name "Bits&Bots Bot"
}
commit_lessons() {
# remove everything except for lessons
rm ./*
cp out/* .
rm -rf out
# Add and commit all lessons
git add -A
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
git checkout -b lesson-pdfs
}
upload_lessons() {
# We can set this to a different location later if preferred, or just
# upload to an S3 bucket etc. Notice this relies currently on an env var
# on the travis server with a bot accounts PAT.
git remote add lesson-pdfs https://${GH_TOKEN}@github.com/bits-and-bots/lessons.git > /dev/null 2>&1
# Make sure nothing is exposed in logs
git push --quiet --set-upstream lesson-pdfs > /dev/null 2>&1
}
if [[ $TRAVIS_BRANCH == 'master' ]]
setup_git
commit_lessons
upload_lessons
fi