Skip to content

Instantly share code, notes, and snippets.

@arodbits
Last active August 21, 2017 14:45
Show Gist options
  • Select an option

  • Save arodbits/56bfaa43b56f2dc8d2880fc45049b3b8 to your computer and use it in GitHub Desktop.

Select an option

Save arodbits/56bfaa43b56f2dc8d2880fc45049b3b8 to your computer and use it in GitHub Desktop.
Build ember files for the different sites
#!/bin/sh
set -e
ROOTDIR=$PWD
INSPECTDIR="htdocs/ember_app"
LASTSHA=$(git fetch $1 && git log --oneline -n 1 | awk '{print $1}')
EXISTS=$(git branch -r --contains $LASTSHA)
if [ ${#EXISTS} -gt "0" ]; then
exit 0
else
#inspect if any file has changed in the inspected directory between the current commit and the previous commit.
FILECOUNT=$(git diff --name-only HEAD HEAD~ | awk '{print $1}' | awk -v pat="^$INSPECTDIR" '$1 ~ pat' | wc -l)
if [ $FILECOUNT -gt 0 ]; then
echo "****************************\n"
echo "*Building the Ember APP....*\n"
echo "****************************\n"
cd $INSPECTDIR
echo "Building for Production: \n" && ember build --environment=production || echo "Error: The production build Failed."
echo "Building for Stage: \n" && ember build --output-path dist-stage/ --environment=stage || echo "Error: The stage build Failed."
echo "Building for Dev: \n" && ember build --output-path dist-dev/ --environment=development || echo "Error: The dev build Failed."
echo "Building for Local: \n" && ember build --output-path dist-local/ --environment=local || echo "Error: The local build Failed."
echo "\nAdding ember built files to remote...\n"
git add "dist/*"
git add "dist-stage/*"
git add "dist-dev/*"
git add "dist-local/*"
git commit -m "Add ember build files" && git push $1 --no-verify && cd $ROOTDIR
echo "Ignore the following error messages, changes were committed successfully...\n"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment