Skip to content

Commit

Permalink
Slight improvement to the build script
Browse files Browse the repository at this point in the history
Use `git log` instead of mixing `echo -n` and `git rev-parse`
Use `pushd/popd` for better CWD management
  • Loading branch information
iBug committed Sep 9, 2018
1 parent 60b1982 commit 5d276d4
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions script/build
Expand Up @@ -9,17 +9,16 @@ if [[ "$TRAVIS_PULL_REQUEST" =~ ^[0-9]+$ ]]; then
fi


for i in "$@"
do
case $i in
while [ $# -ne 0 ]; do
case $1 in
--dev)
DEV=YES
shift # past argument with no value
;;
*)
# unknown option
;;
esac
shift
done

function force-fetch {
Expand All @@ -38,27 +37,24 @@ force-fetch smokey "https://github.com/Charcoal-SE/SmokeDetector.wiki" &
wait

for file in **/Home.md; do
mv "$file" "`dirname "$file"`/index.md"
mv "$file" "$(dirname "$file")/index.md"
done

./add-front-matter.rb ms/** smokey/** &
./create-data-files.rb &
wait

echo -n "Theme commit: "
git -C ./.tmp rev-parse HEAD
echo -n "MS wiki commit: "
git -C ./ms rev-parse HEAD
echo -n "Smokey wiki commit: "
git -C ./smokey rev-parse HEAD
git -C ./.tmp log -1 --pretty="Theme commit: [%h] %s"
git -C ./ms log -1 --pretty="MS wiki commit: [%h] %s"
git -C ./smokey log -1 --pretty="Smokey wiki commit: [%h] %s"

COMMIT_INFO="$(git log -1 --pretty="[%h] %B")"

rm -r _site/assets # remove old assets

export PAGES_ENV=dotcom # GitHub.com

if [[ ! $DEV ]]; then
if [ -z "$DEV" ]; then
export JEKYLL_ENV=production

bundle exec jekyll algolia push --trace &
Expand All @@ -68,8 +64,8 @@ else
bundle exec jekyll build --incremental --profile --trace
fi

cd _site
cd assets
pushd _site # _site
pushd assets # _site/assets
mkdir -p css images

for file in branding*.css; do
Expand All @@ -79,10 +75,12 @@ for file in charcoal*.png; do
cp "$file" images/charcoal.png
done

cd ..
popd # _site/assets

if [[ ! $DEV ]]; then
git add --all .
git config --global push.default tracking
../push.sh -m "$COMMIT_INFO"
fi

popd # _site

0 comments on commit 5d276d4

Please sign in to comment.