]> git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/utils/docker/run-doc-update.sh
import ceph 16.2.7
[ceph.git] / ceph / src / pmdk / utils / docker / run-doc-update.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2019-2020, Intel Corporation
4
5 set -e
6
7 source `dirname $0`/valid-branches.sh
8
9 BOT_NAME="pmem-bot"
10 USER_NAME="pmem"
11 REPO_NAME="pmdk"
12
13 ORIGIN="https://${DOC_UPDATE_GITHUB_TOKEN}@github.com/${BOT_NAME}/${REPO_NAME}"
14 UPSTREAM="https://github.com/${USER_NAME}/${REPO_NAME}"
15 # master or stable-* branch
16 TARGET_BRANCH=${CI_BRANCH}
17 VERSION=${TARGET_BRANCHES[$TARGET_BRANCH]}
18
19 if [ -z $VERSION ]; then
20 echo "Target location for branch $TARGET_BRANCH is not defined."
21 exit 1
22 fi
23
24 # Clone bot repo
25 git clone ${ORIGIN}
26 cd ${REPO_NAME}
27 git remote add upstream ${UPSTREAM}
28
29 git config --local user.name ${BOT_NAME}
30 git config --local user.email "pmem-bot@intel.com"
31
32 git remote update
33 git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH}
34
35 # Copy man & PR web md
36 cd ./doc
37 make -j$(nproc) web
38 cd ..
39
40 mv ./doc/web_linux ../
41 mv ./doc/web_windows ../
42 mv ./doc/generated/libs_map.yml ../
43
44 # Checkout gh-pages and copy docs
45 GH_PAGES_NAME="gh-pages-for-${TARGET_BRANCH}"
46 git checkout -B $GH_PAGES_NAME upstream/gh-pages
47 git clean -dfx
48
49 rsync -a ../web_linux/ ./manpages/linux/${VERSION}/
50 rsync -a ../web_windows/ ./manpages/windows/${VERSION}/ \
51 --exclude='librpmem' \
52 --exclude='rpmemd' --exclude='pmreorder' \
53 --exclude='daxio'
54
55 rm -r ../web_linux
56 rm -r ../web_windows
57
58 if [ $TARGET_BRANCH = "master" ]; then
59 [ ! -d _data ] && mkdir _data
60 cp ../libs_map.yml _data
61 fi
62
63 # Add and push changes.
64 # git commit command may fail if there is nothing to commit.
65 # In that case we want to force push anyway (there might be open pull request
66 # with changes which were reverted).
67 git add -A
68 git commit -m "doc: automatic gh-pages docs update" && true
69 git push -f ${ORIGIN} $GH_PAGES_NAME
70
71 GITHUB_TOKEN=${DOC_UPDATE_GITHUB_TOKEN} hub pull-request -f \
72 -b ${USER_NAME}:gh-pages \
73 -h ${BOT_NAME}:${GH_PAGES_NAME} \
74 -m "doc: automatic gh-pages docs update" && true
75
76 exit 0