Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build script #100

Closed
samgnaniah opened this issue Jun 29, 2019 · 1 comment
Closed

Update build script #100

samgnaniah opened this issue Jun 29, 2019 · 1 comment

Comments

@samgnaniah
Copy link
Contributor

samgnaniah commented Jun 29, 2019

Jenkins build: https://wso2.org/jenkins/job/docs/job/docs-ei/configure

Sample script:

#!/bin/bash

set -o xtrace

#install needed versions

export LC_ALL=C.UTF-8
export LANG=C.UTF-8

apt-cache show python3
apt-cache show python3-pip

apt-get install python3 -y
apt-get install python3-pip -y
ls /usr/bin/p*

alias python='python3'
alias pip=pip3
alias python

pip install virtualenv
virtualenv /env --python=/usr/bin/python3
export PATH=/env/bin:$PATH
echo $PATH

which python3
which python

pip install --upgrade pip

pip install --upgrade mkdocs
pip install Pygments
pip install pymdown-extensions

pip install -U --no-deps mkdocs-material==4.1.1

which mkdocs
pip install markdown-include

apt-get install jq 

echo == versions ==

pip --version
python --version
mkdocs --version
pip freeze | grep mkdocs-material

echo ==============


echo == Build Script Start ==

cwd=`pwd`

#use for checkout and build a particular branch

build(){

 git checkout $1  
 version=$1
 echo ${version}
    
#rename master to next

 if [ "$1" == "master" ]; then
   version="next"
   echo master branch
 fi
    
#obtain particular lang folder
#create folder structure
#build a particular branch

 for dir in ${cwd}/*/; do      
  if [ -d ${f} ]; then
   dir=${dir%*/}
   dirName=${dir##*/}
    if [ ${dirName} != "dist" ]; then
     mkdir -p dist/${dirName}       
     cd ${dir}

########
ADD NEW LOGIC

cd ballerina-integrator
mkdocs build

cd ../micro-...
mkdocs build

cd ..
mv -f "${cwd}/${dirName}/ballerina-integrator/site" "${cwd}/dist/${dirName}/${version}/ballerina-integrator" 
...
########

     mkdocs build
     cd ..         
     mv -f "${cwd}/${dirName}/site" "${cwd}/dist/${dirName}/${version}/"    
    fi
  fi
 done
 
}


if [ "$BUILD_ALL" == "true" ]; then #check trigger manually or automatically

   echo build triggered manually
   
#obtain branch names in a git repo       
 for BRANCH in `git branch -a | grep remotes/origin/*` ;
  do   
   git checkout versions
   GIT_BRANCH_NAME="$(cut -d'/' -f3 <<<"$BRANCH")"  
     
#obtain branch names from versions.json and check with the git branches      
   for version in $(cat en/docs/assets/versions.json | jq -r '.all' | jq -r 'keys[]'); do     
    if [ "$GIT_BRANCH_NAME" == "${version}" ]; then 
      build "${version}"
    fi   
   done   
  done 
#these branches must build in each trigger  
      build "versions"
      build "master"
   
else

  echo build triggered automatically 
#obtain committed branch names in a git repo   
  GIT_BRANCH_NAME="$(cut -d'/' -f2 <<<"$GIT_BRANCH")"  
  git checkout versions
    
#obtain branch names from versions.json and check with the git branches            
  for version in $(cat en/docs/assets/versions.json | jq -r '.all' | jq -r 'keys[]'); do
   if [ "$GIT_BRANCH_NAME" == "${version}" ]; then   
   	 build "${version}"   
      
    # else
     # build "$(cat en/docs/assets/versions.json | jq -r '.current')"
   fi      
  done
    
#these branches must build in each trigger     
    build "versions"
    build "master"
     
fi
@samgnaniah
Copy link
Contributor Author

This is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants