Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ The backup script will source this file if present.
## Weekly plot update script

`scripts/update_plots.sh` generates plots with `src/run.py plot` and pushes them
to a clone of the `nipreps.github.io` website. The path to that clone can be
given as an argument and defaults to `$HOME/workspace/nipreps.github.io`.
The script may be run from any directory and validates that the target is a Git
repository.
to the `nipreps.github.io` website. The script clones the repository to a
temporary directory (by default using `git@github.com:nipreps/nipreps.github.io.git`),
writes the plots there, commits and pushes the changes, and removes the
temporary clone. You may pass an alternative repository URL as an argument.
The script may be run from any directory.

Make the script executable:

Expand Down
17 changes: 10 additions & 7 deletions scripts/update_plots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@

set -euo pipefail

REPO_DIR="${1:-$HOME/workspace/nipreps.github.io}"
ASSETS_DIR="$REPO_DIR/docs/assets"
REPO_URL="${1:-git@github.com:nipreps/nipreps.github.io.git}"
TMP_REPO="$(mktemp -d)"

if [ ! -d "$REPO_DIR/.git" ]; then
echo "Error: $REPO_DIR is not a git repository" >&2
exit 1
fi
cleanup() {
rm -rf "$TMP_REPO"
}
trap cleanup EXIT

git clone "$REPO_URL" "$TMP_REPO"

ASSETS_DIR="$TMP_REPO/docs/assets"
mkdir -p "$ASSETS_DIR"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."

python src/run.py plot -o "$ASSETS_DIR"

cd "$REPO_DIR"
cd "$TMP_REPO"
git pull --ff-only
git add docs/assets
if ! git diff --cached --quiet; then
Expand Down