Skip to content

Instantly share code, notes, and snippets.

@Kedrigern
Created October 8, 2016 09:54
Show Gist options
  • Select an option

  • Save Kedrigern/d24b4744fa5658b53b29b5586d4f7319 to your computer and use it in GitHub Desktop.

Select an option

Save Kedrigern/d24b4744fa5658b53b29b5586d4f7319 to your computer and use it in GitHub Desktop.
jekyll deploy

Jekyll deploy

  1. repos je pole repozitářů
  2. ty se projdou aktualizují / naklonují
  3. v rámci daného cyklu se z nich tvoří jekyll weby

Defaultně vytváří složku git s repozitářemi a složku jekyll s vygenerovanými weby.

#!/usr/bin/env bash
repo_url_prefix="https://github.com/pirati-web/"
repo_prefix="./git/"
deploy_prefix="./jekyll/"
jekyll_bin="/usr/local/bin/jekyll"
repos=( strednicechy.pirati.cz jihocesky.pirati.cz )
function prerequisite {
mkdir -p "$deploy_prefix"
mkdir -p "$repo_prefix"
if git --version &> /dev/null; then :
else
echo "No git"
exit 1
fi;
if jekyll -v &> /dev/null; then :
else
echo "No jekyll"
exit 1
fi;
# Nekontroluje jekyll-paginate jekyll-sitemap
}
function j_update() {
git -C "$1" pull
$jekyll_bin build -s "$1" -d "$2"
}
function main_loop() {
for i in $(seq 0 1); do
repo="${repo_prefix}${repos[i]}";
deploy="${deploy_prefix}${repos[i]}";
repo_url="${repo_url_prefix}${repos[i]}.git";
if [ -d "${repo}/.git" ]; then :
else
git clone $repo_url $repo
fi;
if git -C "${repo}" status &> /dev/null; then
j_update "$repo" "$deploy"
else
echo "$repo has no changes";
fi;
git -C "${repo}" pull || git clone "${repo_url}" "${repo}"
done;
}
prerequisite
main_loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment