[Emacs] Add github pages publishing hooks
This commit is contained in:
parent
a87da9360d
commit
d4ad629514
9
dotfiles/emacs.d/bin/git-hooks/post-commit
Executable file
9
dotfiles/emacs.d/bin/git-hooks/post-commit
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$THIS_DIR/../util.sh"
|
||||
|
||||
if readme_was_updated; then
|
||||
update_index
|
||||
commit_index_changes
|
||||
fi
|
20
dotfiles/emacs.d/bin/install_hooks.sh
Executable file
20
dotfiles/emacs.d/bin/install_hooks.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TOP_LEVEL="$(git rev-parse --show-toplevel)"
|
||||
HOOK_DIR="$TOP_LEVEL/.git/hooks"
|
||||
|
||||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SOURCE_DIR="$THIS_DIR/git-hooks"
|
||||
|
||||
for hook in "$SOURCE_DIR"/*; do
|
||||
filename=$(basename "$hook")
|
||||
source="$SOURCE_DIR/$filename"
|
||||
dest="$HOOK_DIR/$filename"
|
||||
# If the hook already exists, is executable, and is not a symlink
|
||||
if [ -e "$dest" ]; then
|
||||
mv "$dest" "$dest.local"
|
||||
fi
|
||||
echo "linking $source to $dest"
|
||||
ln -s "$source" "$dest"
|
||||
chmod 755 "$dest"
|
||||
done
|
6
dotfiles/emacs.d/bin/update_github_page.sh
Executable file
6
dotfiles/emacs.d/bin/update_github_page.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$THIS_DIR/util.sh"
|
||||
|
||||
update_index
|
20
dotfiles/emacs.d/bin/util.sh
Executable file
20
dotfiles/emacs.d/bin/util.sh
Executable file
@ -0,0 +1,20 @@
|
||||
# -*- mode: sh -*-
|
||||
EMACS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
||||
TOP_LEVEL="$(git rev-parse --show-toplevel)"
|
||||
README="$EMACS_DIR/README.org"
|
||||
REPOSITORY_NAME="$(realpath --relative-to="$TOP_LEVEL" "$README")"
|
||||
|
||||
readme_was_updated() {
|
||||
git diff HEAD~1 --name-only | grep --quiet "$REPOSITORY_NAME"
|
||||
}
|
||||
|
||||
update_index () {
|
||||
emacsclient -e "(with-current-buffer (find-file-noselect \"$README\")
|
||||
(org-html-export-to-html))"
|
||||
cp -f "$EMACS_DIR/README.html" "$TOP_LEVEL/index.html"
|
||||
}
|
||||
|
||||
commit_index_changes () {
|
||||
git add "$TOP_LEVEL/index.html"
|
||||
git commit -m "[Emacs] Update github pages index file"
|
||||
}
|
Loading…
Reference in New Issue
Block a user