Skip to content

Commit

Permalink
Deploying docuemntation using Azure
Browse files Browse the repository at this point in the history
Update documentation of build

Change repo label back to main

Only 1 VM

Remove travis yaml file

Remove travis variable

Changed documentation html

Deleted unnecessary lines

Remove sphinx_docs directory

Update Build Documentation Pipeline

Git pull exception, Deploy shell licensce

Specify branch pull before build

Update deploy_docs shell for branch

Documentation and debugging

[skip ci]

Update licence and repo variable for pull

Proof read documentation

Prepare for pr

Correct spelling mistake

[skip ci]

Co-authored-by: Jaladh Singhal <jaladh-singhal@users.noreply.github.com>
  • Loading branch information
2 people authored and --get committed Jun 19, 2019
1 parent b2c14e3 commit 8b7ec6a
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 90 deletions.
90 changes: 0 additions & 90 deletions .travis.yml

This file was deleted.

69 changes: 69 additions & 0 deletions azure-pipelines/doc-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Specify which branches you want to trigger for continuous deployment and/or applicable for pull requests.
# Otherwise it triggers all of them.
trigger:
- master

pr:
- master

# Variables we can reference later.
variables:
system.debug: 'true'
tardis.build.dir: $(Build.Repository.LocalPath)


jobs:
# Title of job
# Virtual machine selected from the available pools.
- job: 'Build_Documentation'
pool:
vmImage: 'Ubuntu-16.04'

steps:
# When setting up the azure pipeline for the first time, generate a ssh key locally
# and add the generated public key to github as a deploy key through forked_repo_home/settings/deploy_key.
# Use steps listed from: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/install-ssh-key?view=azure-devops#example-setup-using-github.

# Secure files stored in the azure server are encryped and again decrypted by the azure task that uses the file.
# Download a secure file to a temporary location in the virtual machine.
- task: DownloadSecureFile@1
inputs:
secureFile: 'id_azure_rsa'
# Make sure you've added the generated private key file (named 'id_azure_rsa' here) to library & authorize it for all pipelines.
# by using: https://docs.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops#how-do-i-authorize-a-secure-file-for-use-in-all-pipelines

# Install an SSH key prior to a build or release.
# This is needed to give azure access to deploy to github.
# hostName is the line that was added to ~/.ssh/known_hosts when you added the RSA host key. (Output of ssh-keyscan should look something like: [1]As3..=ssh-rsa ..).
# sshPublicKey should be a string value of what is inside your .pub file (i.e: rsa-key Axddd... username@server).
# sshKeySecureFile is the downloaded secure file you generated.
- task: InstallSSHKey@0
inputs:
hostName: $(gh_host)
sshPublicKey: $(public_key)
#sshPassphrase: $(Agent.TempDirectory) # Optional - leave empty if it was left empty while generating the key.
sshKeySecureFile: 'id_azure_rsa'
# You can mask hostName & sshPublicKey values under secret variables (i.e. gh_host & public_key here) in your azure pipeline build page.
# Follow these steps: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables

# ##vso[task.prependpath] is a built-in logging command to add paths.
# Add conda to the list of paths available from the terminal.
- bash: |
echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
# Make the vm user the owner of the conda path.
# Update conda without asking for confirmation.
- bash: |
sudo chown -R $USER $CONDA
conda update -y conda
displayName: updating conda and activating
# Install the conda environment made for tardis.
- bash: |
sh ci-helpers/install_tardis_env.sh
displayName: 'Install TARDIS env'
# Activate the environment, use sphinx to make the html documentation of the build, and deploy to gh-pages.
- bash: |
source activate tardis
bash deploy_docs.sh
displayName: 'TARDIS build and deployment to gh-pages'
# See github.com/tardis-sn/tardis for the contents of these files.
59 changes: 59 additions & 0 deletions deploy_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Modified from https://github.com/AMReX-Codes/amrex/blob/master/build_and_deploy.sh
# and licensed according to BSD-3-Clause-LBNL (https://github.com/AMReX-Codes/amrex/blob/master/LICENSE).

#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Build the documentation from the SOURCE_BRANCH
# and push it to TARGET_BRANCH.
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"

# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone $REPO out
cd out

git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..

# Clean out existing contents
rm -rf out/sphinx_docs/ || exit 0

# Pull from SOURCE_BRANCH again
git pull $SSH_REPO $SOURCE_BRANCH

# Build the Sphinx documentation
cd docs
make html
cd ../

mkdir -p out/sphinx_docs/
mv -f docs/_build/html/* out/sphinx_docs/
touch out/.nojekyll

# Now let's go have some fun with the cloned repo
cd out
git config --local user.name "Azure Pipelines"
git config --local user.email "azuredevops@microsoft.com"

echo "doing git add/commit/push"

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add --all

# Exit if there are no docs changes
if git diff --staged --quiet; then
echo "exiting with no docs changes"
exit 0
fi

# Otherwise, commit and push
git commit -m "Deploy to GitHub Pages: ${SHA}"
git push $SSH_REPO $TARGET_BRANCH

0 comments on commit 8b7ec6a

Please sign in to comment.