Skip to content

Commit

Permalink
dev site workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thurber committed Jan 8, 2024
1 parent 6bbe199 commit 50b7790
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/01_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [ main ]
branches: [ main, feature/dev-site ]

jobs:
build:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/02_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ jobs:
run: npm run build
- name: Commit documentation changes
run: |
cd landing/build
git clone --depth=1 --branch=gh-pages https://github.com/IMMM-SFA/msd_uncertainty_ebook.git previous_deploy
mkdir ./landing/build/dev
cp -r ./previous_deploy/dev/* ./landing/build/dev/
cd ./landing/build
git init
git add -A
git config --local user.email "[email protected]"
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/03_dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Deploy

on:
push:
branches: [ feature/dev-site ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install latex dependencies
run: sudo apt-get update -y && sudo apt-get install -y texlive latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended ghostscript
- name: Update pip and install python dependencies
working-directory: 'docs/'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build html and pdf ebook
working-directory: 'docs/'
env:
NODE_ENV: development
run: |
make html latexpdf --keep-going LATEXMKOPTS="-interaction=nonstopmode" || true
make latexpdf --keep-going LATEXMKOPTS="-interaction=nonstopmode" || true
make latexpdf --keep-going LATEXMKOPTS="-interaction=nonstopmode" || true
continue-on-error: true
- name: Concatenate eBook cover with eBook
run: |
mv docs/build/latex/addressinguncertaintyinmultisectordynamicsresearch.pdf docs/build/latex/ebook_content.pdf
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=docs/build/latex/addressinguncertaintyinmultisectordynamicsresearch.pdf -dBATCH docs/ebook_cover.pdf docs/build/latex/ebook_content.pdf
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: landing/package-lock.json
- uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
SOURCE_DIR: 'notebooks'
DEST_DIR: 'notebooks'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DEV }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
AWS_REGION: ${{ secrets.AWS_REGION_DEV }}
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile_dev
push: true
tags: thurber/uc-ebook.org:dev
- name: Install landing page dependencies
working-directory: 'landing/'
run: npm install
- name: Build landing page
working-directory: 'landing/'
env:
NODE_ENV: development
VITE_PDF_URL: https://uc-ebook.org/dev/images/addressinguncertaintyinmultisectordynamicsresearch.pdf
run: npm run build
- name: Commit documentation changes
run: |
git clone --depth=1 --branch=gh-pages https://github.com/IMMM-SFA/msd_uncertainty_ebook.git deploy
rm -rf ./deploy/.git
rm -rf ./deploy/dev
mkdir ./deploy/dev
cp -r ./landing/build/* ./deploy/dev/
cp ./docs/build/latex/addressinguncertaintyinmultisectordynamicsresearch.pdf ./deploy/dev/images/
cd ./deploy
git init
git add -A
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m 'deploy' -a || true
- name: Push changes to gh-pages
uses: ad-m/github-push-action@master
with:
branch: gh-pages-test
directory: deploy
force: true
github_token: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM jupyter/minimal-notebook:2022-05-03

USER root

RUN git clone --depth=1 --branch=feature/dev-site https://github.com/IMMM-SFA/msd_uncertainty_ebook.git msd_uncertainty_ebook
RUN cd msd_uncertainty_ebook && pip install .

# Now create a symlinked data folder inside the msdbook package that links to /home/demo/data folder
RUN mkdir -p /home/demo/data
RUN rm -rf /opt/conda/lib/python3.9/site-packages/msdbook/data
RUN ln -s /home/demo/data /opt/conda/lib/python3.9/site-packages/msdbook/data


20 changes: 12 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@
sys.path.insert(0, os.path.abspath('../../'))
sys.path.append(os.path.abspath("../../extensions"))

# if this is a dev build, the paths need to be adjusted
dev_web = '/dev' if ('NODE_ENV' in os.environ and os.environ['NODE_ENV'] == 'development') else ''
dev_nb = '.dev' if ('NODE_ENV' in os.environ and os.environ['NODE_ENV'] == 'development') else ''

# current datetime to use as the version
today = f"Last updated: {datetime.utcnow().strftime('%b %d, %Y')}"


# -- Notebook URLs -----------------------------------------------------------

rst_prolog = """
.. _nb_logistic_regression: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/basin_users_logistic_regression.ipynb
.. _nb_saltelli_sobol: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/sa_saltelli_sobol_ishigami.ipynb
.. _nb_hymod: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/hymod.ipynb
.. _nb_fishery_dynamics: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/fishery_dynamics.ipynb
.. _nb_discovery: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/Bedford_Greene_SD_tutorial.ipynb
.. _nb_hmm: https://uc-ebook.msdlive.org/user-redirect/lab/tree/notebooks/Hidden-Markov_Modeling_Approaches_to_Creating_Synthetic_Streamflow_Scenarios.ipynb
rst_prolog = f"""
.. _nb_logistic_regression: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/basin_users_logistic_regression.ipynb
.. _nb_saltelli_sobol: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/sa_saltelli_sobol_ishigami.ipynb
.. _nb_hymod: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/hymod.ipynb
.. _nb_fishery_dynamics: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/fishery_dynamics.ipynb
.. _nb_discovery: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/Bedford_Greene_SD_tutorial.ipynb
.. _nb_hmm: https://uc-ebook{dev_nb}.msdlive.org/user-redirect/lab/tree/notebooks/Hidden-Markov_Modeling_Approaches_to_Creating_Synthetic_Streamflow_Scenarios.ipynb
"""


Expand Down Expand Up @@ -88,7 +92,7 @@

# theme options
html_theme_options = {
'path_to_docs': '/docs',
'path_to_docs': f'{dev_web}/docs',
'repository_url': 'https://github.com/IMMM-SFA/msd_uncertainty_ebook',
'use_issues_button': True,
'use_download_button': True,
Expand Down
2 changes: 1 addition & 1 deletion landing/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = {
assets: 'build'
}),
paths: {
base: ''
base: process.env.NODE_ENV === 'development' ? '/dev' : ''
}
}
};
Expand Down

0 comments on commit 50b7790

Please sign in to comment.