Created
March 11, 2016 07:17
-
-
Save jacwright/92895aa1f91a93be2527 to your computer and use it in GitHub Desktop.
For Chip, copy docs to jekyll website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Copies the docs over to the website repository and commits it | |
folder_name=${PWD##*/} | |
LAYOUT_PREFIX='---\r\nlayout: default\r\n---\r\n\r\n' | |
mkdir -p "../chip-js.github.io/docs/$folder_name" | |
if [ -d "docs" ]; then | |
cp -R docs/*.md "../chip-js.github.io/docs/$folder_name" | |
else | |
cp README.md "../chip-js.github.io/docs/$folder_name" | |
fi | |
cd ../chip-js.github.io | |
FILES="docs/$folder_name/*" | |
for file in $FILES | |
do | |
echo $LAYOUT_PREFIX | cat - "$file" > temp && mv temp "$file" | |
done | |
if [ -e "docs/$folder_name/README.md" ]; then | |
mv "docs/$folder_name/README.md" "docs/$folder_name/index.md" | |
fi | |
git add docs | |
git commit -a -m "Sync docs from chip-js/$folder_name to docs" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can make this work by putting the file into the
.git/hooks/
directory of each repository you want to copy docs from. The file must be executable, so be sure to runchmod +x .git/hooks/post-commit
to make it work. And you can test it by simply calling it,.git/hooks/post-commit
.This will copy the README.md over if there is no docs folder. And it will rename the README.md from docs or root to
index.md
so that it will be loaded at the root of the directory like it is on github.