Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Created November 2, 2022 05:16
Show Gist options
  • Save rwcitek/0536644992ef3ba8cbd40bbc213dbd57 to your computer and use it in GitHub Desktop.
Save rwcitek/0536644992ef3ba8cbd40bbc213dbd57 to your computer and use it in GitHub Desktop.
Creating a GH pages slide deck inside an existing repo
# This gist combines specific commits from two different repos: jekyll-and-slide and reveal.js
# - https://github.com/adamhollett/jekyll-and-slide
# - https://github.com/hakimel/reveal.js
# If there was a way to do this from the browser, this gist would be unnecessary.
# prerequisite: an existing repo in GitHub, no branch named "gh-pages", and note repo URL
REMOTE_URL='https://github.com/sluugdemogithub/demo03.git'
# create the URL for GitHub Pages
<<< "$REMOTE_URL" IFS='/' read scheme x host id repo
PAGES_URL="${scheme}//${id}.${host%com}io/${repo%.*}"
# do the following in a bash or equivalent shell
tmpdir=$( mktemp -d /tmp/gh-slidedeck.XXXXXX )
cd ${tmpdir}
# fetch jekyll-and-slide and reaveal.js
curl -L -o jekyll-and-slide.zip https://github.com/adamhollett/jekyll-and-slide/archive/3a9da81031cc48fa4b04f90d8872b8d6c5014c8c.zip
curl -L -o reveal-js.zip https://github.com/hakimel/reveal.js/archive/bef2722eedd9671a9e0f0f9e553c0863437d1402.zip
# setup Jekyll
unzip ${tmpdir}/jekyll-and-slide.zip
mv jekyll-and-slide-* jekyll-and-slide
cd jekyll-and-slide
rm -rf reveal.js/ .gitmodules
sed -i -e "/^url:/s#http.*#${PAGES_URL}#;/^baseurl:/s#/.*#/${repo%.*}#" _config.yml
# setup reveal.js
unzip ${tmpdir}/reveal-js.zip
mv reveal.js-* reveal.js
# clone, create new "gh-pages" branch from first commit, and cleanup
cd ${tmpdir}
git clone ${REMOTE_URL}
cd ${repo%.*}
git config --local user.name "demo"
git config --local user.email "[email protected]"
git log | grep ^commit | tail -n -1 | cut -d" " -f2 | xargs -n 1 git checkout -b gh-pages
find ./* -type f | xargs git ls-files | xargs git rm -f --
git commit -am "clean up"
mv .git ${tmpdir}/jekyll-and-slide
cd ${tmpdir}/jekyll-and-slide
# add and commit
git add .
git commit -m "gh-pages initial commit"
# push to the remote repo on GitHub
git remote add origin "${REMOTE_URL}"
git push origin gh-pages
rm -rf ${tmpdir}
# enable Pages on GitHub repo page using the "gh-pages" branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment