2017-04-29 23:43:33 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Store the versions
|
2017-10-12 12:21:57 +08:00
|
|
|
VERSION=$(node -e "process.stdout.write(require('./package.json').version)")
|
2017-08-19 00:13:37 +08:00
|
|
|
HEAD=$(git rev-parse HEAD)
|
2017-04-29 23:43:33 +08:00
|
|
|
|
|
|
|
# Generate docs
|
|
|
|
npm run doc
|
|
|
|
|
2017-08-18 23:55:11 +08:00
|
|
|
# Checkout the website into the tmp directory
|
|
|
|
[ -d tmp/website ] || {
|
2017-10-14 20:57:25 +08:00
|
|
|
REPO=https://github.com/probot/probot.github.io
|
|
|
|
|
|
|
|
# If GH_TOKEN environment variable is present, use that to push.
|
|
|
|
if [[ -n "$GH_TOKEN" ]]; then
|
|
|
|
REPO=${REPO/https:\/\//https://${GH_TOKEN}@}
|
|
|
|
fi
|
|
|
|
|
2017-08-18 23:55:11 +08:00
|
|
|
mkdir -p tmp
|
2017-10-14 20:57:25 +08:00
|
|
|
git clone $REPO tmp/website
|
2017-08-18 23:55:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Update the website checkout
|
|
|
|
cd tmp/website
|
|
|
|
git pull origin master
|
2017-04-29 23:43:33 +08:00
|
|
|
|
|
|
|
# Delete previously generated docs for this version
|
2017-08-18 23:55:11 +08:00
|
|
|
rm -rf api/$VERSION
|
|
|
|
|
|
|
|
# Copy over the new docs
|
2018-06-27 07:02:59 +08:00
|
|
|
mv ../../out api/$VERSION
|
2017-04-29 23:43:33 +08:00
|
|
|
|
2017-08-19 00:13:37 +08:00
|
|
|
# Update the /api/latest link to point to this version
|
2017-08-18 23:55:11 +08:00
|
|
|
ln -sfn $VERSION api/latest
|
2017-04-29 23:43:33 +08:00
|
|
|
|
2017-08-19 00:13:37 +08:00
|
|
|
# Update the submodule
|
|
|
|
git submodule update --init
|
|
|
|
cd _submodules/probot
|
|
|
|
git fetch
|
|
|
|
git checkout $HEAD
|
|
|
|
cd ../..
|
|
|
|
|
2017-04-29 23:43:33 +08:00
|
|
|
# Commit and publish
|
|
|
|
git add .
|
|
|
|
git commit -m "Update docs for v$VERSION"
|
2017-08-19 00:13:37 +08:00
|
|
|
git tag -f v$VERSION
|
2017-08-18 23:55:11 +08:00
|
|
|
git push --tags origin master
|