blob: 9cbef8ddc9a6e9ea4780ee63542181c824684a77 [file] [log] [blame]
John DeNisco73f725c2019-10-29 10:40:09 -04001#!/bin/bash -ex
2
3# publish-docs.sh
4#
5# This sccript is used to publish the VPP User documents to
6# the FD.io Site.
7#
8# Arguments:
9#
10# $1: The main site repo user name
11# $2: The release branch name for example 1908, 1904 etc.
12
13# Some basic checks
14if [ ! -d "docs" ]; then
15 echo "This script is meant to be run from the root directory."
16 exit 1;
17fi
18
19if [ "$#" -ne 2 ]; then
20 echo "Please specify the site username and branch."
21 exit 1;
22fi
23
24# Get the workspace root
25WS_ROOT=$PWD
26
27# Get the VPP branch and username
28SITE_USERNAME=$1
29VPP_BRANCH=$2
30
31#Build the docs
John DeNiscoa273ce62020-01-24 14:04:41 -050032make docs-clean
John DeNisco73f725c2019-10-29 10:40:09 -040033make docs-venv
34make docs
35
36# Clone the site repo
37rm -fr site
38git clone ssh://git@github.com/$SITE_USERNAME/site
39cd site
40git submodule update --init --recursive
41git remote add upstream ssh://git@github.com/FDio/site
42git remote -v
43git fetch upstream
44git merge -m "Publish the Docs" upstream/master
45
46# Get the version
47VERSION=`source $WS_ROOT/src/scripts/version`
48VERSION=${VERSION/"~"/"-"}
49
John DeNisco73f725c2019-10-29 10:40:09 -040050# Copy the files to the appropriate directory
51SRC_DIR=../docs/_build/html/.
52if [ "$VPP_BRANCH" == "master" ]
53then
54 TARGET_DIR=./static/docs/vpp/master
John DeNiscoa273ce62020-01-24 14:04:41 -050055 rm -fr $TARGET_DIR
John DeNisco73f725c2019-10-29 10:40:09 -040056else
57 TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH
John DeNiscoa273ce62020-01-24 14:04:41 -050058 rm -fr $TARGET_DIR
59 mkdir -p $TARGET_DIR
60 VERSION=v$VPP_BRANCH
61 ln -s $VERSION ./static/docs/vpp/latest
John DeNisco73f725c2019-10-29 10:40:09 -040062fi
63
John DeNiscoa273ce62020-01-24 14:04:41 -050064# Create a branch for the commit
65git checkout -b $VERSION
66git branch
67
68# Copy the docs
John DeNisco73f725c2019-10-29 10:40:09 -040069cp -r $SRC_DIR $TARGET_DIR
70
71# Push the new docs
John DeNiscoa273ce62020-01-24 14:04:41 -050072#git add "*"
73#git commit -s -m "Publish docs from VPP $VERSION"
74#git push origin "$VERSION"
John DeNisco73f725c2019-10-29 10:40:09 -040075
76exit 0