forked from WxWatch/riot-api-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis-push.sh
37 lines (33 loc) · 1.07 KB
/
.travis-push.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
#!/bin/sh
# Credit: https://gist.github.com/willprice/e07efd73fb7f13f917ea
setup_git() {
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
}
commit_libraries_rst() {
git fetch
# Stash changes
git stash
git checkout master
# Unstash
git stash apply
# Current month and year, e.g: Apr 2018
dateAndMonth=`date "+%b %Y"`
# Stage the modified files in dist/output
git add -f docs/libraries.rst
# Create a new commit with a custom build message
# with "[skip ci]" to avoid a build loop
# and Travis build number for reference
git commit -m "Travis update: $dateAndMonth (Build $TRAVIS_BUILD_NUMBER)" -m "[skip ci]"
}
upload_files() {
# Remove existing "origin"
git remote rm origin
# Add new "origin" with access token in the git URL for authentication
git remote add origin https://wxwatch:${GITHUB_TOKEN}@github.com/wxwatch/riot-api-libraries.git > /dev/null 2>&1
git push origin master --quiet
}
setup_git
commit_libraries_rst
upload_files