Skip to content

Instantly share code, notes, and snippets.

@jacwright
Created March 11, 2016 07:17
Show Gist options
  • Save jacwright/92895aa1f91a93be2527 to your computer and use it in GitHub Desktop.
Save jacwright/92895aa1f91a93be2527 to your computer and use it in GitHub Desktop.
For Chip, copy docs to jekyll website
#!/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
@jacwright
Copy link
Author

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 run chmod +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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment