Skip to content

Commit

Permalink
feat(github): add gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jfishe committed Nov 9, 2024
1 parent cc7843e commit 0908585
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_install_hook_types:
- pre-commit
- pre-push

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/sirosen/texthooks
rev: 0.6.7
hooks:
- id: fix-smartquotes
- id: fix-ligatures
- id: fix-spaces
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# args:
# - "--write-changes"
- repo: local
hooks:
- id: ghp-import
name: Update Github Pages
entry: .pre_commit_hooks/gh-pages.sh
language: script
require_serial: true
stages:
- pre-push
verbose: true
34 changes: 34 additions & 0 deletions .pre_commit_hooks/gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# pre-commit hook using ghp-import to push HTML to Github Pages.
# Assumes:
# HTML exists in docs folder.
# ghp-import in PATH, e.g., `python -m pip install ghp-import`.
# `git config ghppages.pathhtml <absolute path>/docs`. Defaults to
# "$GIT_WORK_TREE/docs".
# `git config ghppages.push true`. Otherwise skip publishing.

if git config --get-colorbool color.interactive
then
# See https://github.com/vimwiki/vimwiki/blob/master/doc/logo.svg
say_prefix='\e[90mghp\e[92m|\e[37mimport\e[0m'
else
say_prefix='ghp-import'
fi

say () {
printf '%b: %s' "$say_prefix" "$*"
}

say_done () {
printf 'done.\n'
}

# Update gh-pages
if test "$(git config --bool ghppages.push || echo false)" = true
then
pathhtml=$(git config ghppages.pathhtml || echo "$GIT_WORK_TREE/docs")
say 'Pushing html to gh-pages...'
make html
ghp-import -n -o -p -f "$pathhtml"
say_done
fi
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- editorconfig
- pandoc[version='>=3.5']
- panflute
- pre-commit
- python [version='>=3.9']
# - pip
# - pip:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ghp-import
MarkdownPP

0 comments on commit 0908585

Please sign in to comment.