#!/bin/bash # Helper script to update figures on paper repository. PAPER_REPO="https://git.rwth-aachen.de/john.doe/XXXXXXXX.git" git config --global credential.helper store git clone $PAPER_REPO paper_repo/ # Extract the images from the Notebook. jupyter nbconvert --to markdown --output paper_figure.md $1 rm paper_figure.md mkdir -p paper_repo/figures mv paper_figure_files/* paper_repo/figures rmdir paper_figure_files cd paper_repo if [ $(git config --global user.email) ]; then git add . git commit -m "Update figures" git push origin master else echo "Unable to auto-detect email address. Run git config --global user.email 'firstname.lastname@example.org'" fi # Cleanup cd .. rm -rf paper_repo
Before you even run the script you need to modify the first line, which will point to the paper repository. The script is written in a way that it is assumed that the paper repository is private and that this script is executed on the Lichtenberg cluster where there git and jupyter are not installed. So in order for the script to work you need to work from the insides of a Singularity container where git and jupyter are installed.
The first time the script is run, the username and password are going to be requested, since the script uses https in order to
the project. But after that first time (unless you clean the git store cache), the username/password are not going to be asked again. Furthermore, the user needs to provide an email to the git (
git config --global user.email 'email@example.com').
git store will save the credentials as a plaintext file inside your home folder.
jupyter nbconvertcommand will convert the .ipynb file to a Markdown file (.md) where in the process it will also create a folder with all the images of the notebook.
The notebook has to be already executed in some way so the figures are available already.