11#! /usr/bin/env bash
22#
3- # Copyright 2018, Intel Corporation
3+ # Copyright 2018-2020 , Intel Corporation
44#
55# Redistribution and use in source and binary forms, with or without
66# modification, are permitted provided that the following conditions
3232
3333set -e
3434
35- ORIGIN=" https://${GITHUB_TOKEN} @github.com/pmem-bot/libpmemobj-cpp"
36- UPSTREAM=" https://github.com/pmem/libpmemobj-cpp"
35+ source ` dirname $0 ` /valid-branches.sh
36+
37+ BOT_NAME=" pmem-bot"
38+ USER_NAME=" pmem"
39+ REPO_NAME=" libpmemobj-cpp"
40+
41+ ORIGIN=" https://${GITHUB_TOKEN} @github.com/${BOT_NAME} /${REPO_NAME} "
42+ UPSTREAM=" https://github.com/pmem/${REPO_NAME} "
43+ # master or stable-* branch
44+ TARGET_BRANCH=${TRAVIS_BRANCH}
45+ VERSION=${TARGET_BRANCHES[$TARGET_BRANCH]}
46+
47+ if [ -z $VERSION ]; then
48+ echo " Target location for branch $TARGET_BRANCH is not defined."
49+ exit 1
50+ fi
3751
3852# Clone repo
3953git clone ${ORIGIN}
40- cd libpmemobj-cpp
54+ cd ${REPO_NAME}
4155git remote add upstream ${UPSTREAM}
4256
43- git config --local user.name " pmem-bot "
44- git config --local user.email " pmem-bot @intel.com"
57+ git config --local user.name ${BOT_NAME}
58+ git config --local user.email " ${BOT_NAME} @intel.com"
4559
46- git checkout master
4760git remote update
48- git rebase upstream/master
61+ git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH}
4962
5063# Build docs
5164mkdir build
@@ -58,20 +71,26 @@ cp -R doc/cpp_html ../..
5871cd ..
5972
6073# Checkout gh-pages and copy docs
61- git checkout -fb gh-pages upstream/gh-pages
62- git clean -df
63- cp -r ../cpp_html/* master/doxygen/
74+ GH_PAGES_NAME=" gh-pages-for-${TARGET_BRANCH} "
75+ git checkout -B $GH_PAGES_NAME upstream/gh-pages
76+ git clean -dfx
77+
78+ # Clean old content, since some files might have been deleted
79+ rm -r ./$VERSION
80+ mkdir -p ./$VERSION /doxygen/
81+
82+ cp -r ../cpp_html/* ./$VERSION /doxygen/
6483
6584# Add and push changes.
6685# git commit command may fail if there is nothing to commit.
6786# In that case we want to force push anyway (there might be open pull request with
6887# changes which were reverted).
6988git add -A
7089git commit -m " doc: automatic gh-pages docs update" && true
71- git push -f ${ORIGIN} gh-pages
90+ git push -f ${ORIGIN} $GH_PAGES_NAME
7291
7392# Makes pull request.
7493# When there is already an open PR or there are no changes an error is thrown, which we ignore.
75- hub pull-request -f -b pmem :gh-pages -h pmem-bot:gh-pages -m " doc: automatic gh-pages docs update" && true
94+ hub pull-request -f -b ${USER_NAME} :gh-pages -h ${BOT_NAME} : ${GH_PAGES_NAME} -m " doc: automatic gh-pages docs update" && true
7695
7796exit 0
0 commit comments