Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added files for docs deployment pipeline
- Loading branch information
1 parent
e76b26f
commit e4b0940
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# Build the documentation from the SOURCE_BRANCH | ||
# and push it to TARGET_BRANCH. | ||
SOURCE_BRANCH="master" | ||
TARGET_BRANCH="gh-pages" | ||
|
||
|
||
# Store some useful information | ||
REPO=`git config remote.origin.url` | ||
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} | ||
SHA=`git rev-parse --verify HEAD` # Latest SHA Commit | ||
|
||
# SOURCE_BRANCH (master) can be acessed from default dir at VM | ||
# To access TARGET_BRANCH (gh-pages) alongside it, we use out/ dir | ||
git clone $REPO out | ||
cd out | ||
# If gh-pages doesn't exist yet (should only happen on first deploy), | ||
# create a new empty (orphan) branch | ||
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH | ||
# Clean out existing contents | ||
git rm -rf . || exit 0 | ||
# Move back to SOURCE_BRANCH | ||
cd .. | ||
|
||
|
||
# Build the Sphinx documentation | ||
python setup.py build_docs | ||
# Move built docs to out/ | ||
mv -f docs/_build/html/* out/ | ||
touch out/.nojekyll | ||
|
||
|
||
# Move again to out/ (TARGET_BRANCH) | ||
cd out | ||
git config --local user.name "Azure Pipelines" | ||
git config --local user.email "azuredevops@microsoft.com" | ||
|
||
echo "Doing git add/commit/push" | ||
# Stage all the "changes" i.e. the new version | ||
git add --all | ||
|
||
# Exit if there are no difference between new & older version | ||
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 | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Specify branches to trigger for Continuous Deployment (including those for PRs) | ||
trigger: | ||
- master | ||
|
||
pr: | ||
- master | ||
|
||
pool: | ||
vmImage: 'ubuntu-16.04' | ||
|
||
# Before setting up this pipeline (creating this yml file 1st time), make sure to generate a ssh key locally | ||
# And add public key (from generated rsa pair of keys) to github at repo>settings>deploy_key | ||
# Use steps at: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/install-ssh-key?view=azure-devops#example-setup-using-github | ||
|
||
steps: | ||
# Download a secure file to a temporary location on the build/release agent (VM) | ||
- task: DownloadSecureFile@1 | ||
inputs: | ||
secureFile: 'id_wsp_azure_rsa' | ||
# id_wsp_azure_rsa is the generated private key file i.e. added & authorized from library tab of azure pipelines | ||
|
||
# Install an SSH key prior to a build/release to give azure access to deploy | ||
- task: InstallSSHKey@0 | ||
inputs: | ||
hostName: $(gh_host) | ||
sshPublicKey: $(public_key) | ||
#sshPassphrase: Optional (since not used while generating ssh key) | ||
sshKeySecureFile: 'id_wsp_azure_rsa' | ||
# gh_host & public_key are secret variables defined in the azure pipeline page for masking actual values | ||
|
||
- bash: | | ||
echo "##vso[task.prependpath]$CONDA/bin" | ||
displayName: Add conda to PATH | ||
- bash: | | ||
sudo chown -R $USER $CONDA | ||
conda update -y conda | ||
displayName: Update conda and activate it | ||
# Build & deploy docs from python3 environment. Hence use starkit_env3.yml | ||
- bash: | | ||
curl -O https://raw.githubusercontent.com/starkit/starkit/master/starkit_env3.yml | ||
conda env create -n starkit --file ./starkit_env3.yml | ||
displayName: 'Create starkit python3 environment' | ||
- bash: | | ||
source activate starkit | ||
pip install git+https://github.com/starkit/starkit | ||
displayName: Install starkit (since it is required by wsynphot) | ||
- bash: | | ||
source activate starkit | ||
bash azure_pipelines/deploy_docs.sh | ||
displayName: Build wsynphot docs & Deploy to gh-pages |