blob: 0a81dc07212032671f314de53b8616d0989f53c6 [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
32make docs-venv
33make docs
34
35# Clone the site repo
36rm -fr site
37git clone ssh://git@github.com/$SITE_USERNAME/site
38cd site
39git submodule update --init --recursive
40git remote add upstream ssh://git@github.com/FDio/site
41git remote -v
42git fetch upstream
43git merge -m "Publish the Docs" upstream/master
44
45# Get the version
46VERSION=`source $WS_ROOT/src/scripts/version`
47VERSION=${VERSION/"~"/"-"}
48
49# Create a branch for the commit
50git checkout -b $VERSION
51git branch
52
53# Copy the files to the appropriate directory
54SRC_DIR=../docs/_build/html/.
55if [ "$VPP_BRANCH" == "master" ]
56then
57 TARGET_DIR=./static/docs/vpp/master
58 rm -fr ./static/docs/vpp/master
59else
60 TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH
61 rm -fr ./static/docs/vpp/$TARGET_DIR
62 mkdir -p ./static/docs/vpp/$TARGET_DIR
63fi
64
65cp -r $SRC_DIR $TARGET_DIR
66
67# Push the new docs
68git add "*"
69git commit -s -m "Publish docs from VPP $VERSION"
70git push origin "$VERSION"
71
72exit 0