Skip to content

Instantly share code, notes, and snippets.

@HeshamMeneisi
Created November 14, 2019 05:40
Show Gist options
  • Save HeshamMeneisi/8d488956ef8c50b0ac6470dac818e96c to your computer and use it in GitHub Desktop.
Save HeshamMeneisi/8d488956ef8c50b0ac6470dac818e96c to your computer and use it in GitHub Desktop.
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]
Build frontend.
Arguments:
-d Dev-mode (This will skip any production-specific operations)
-s Push stable to docker.io, ignored in dev-mode. (auto-set by "feat:*" commit)
-b Build image (auto-set after a new commit)
EOF
}
WD=$(pwd)
info(){
echo -e "\e[34m$1\e[0m"
}
success(){
echo -e "\e[32m✓ $1\e[0m"
}
error(){
echo -e "\e[31m✗ $1\e[0m"
}
warning(){
echo -e "\e[43m⚠️ $1\e[0m"
}
dev=1
stable=-1
rebuild=-1
while getopts "bdhsu" arg; do
if [ -n "$OPTARG" ] && [ "$OPTARG" -eq "$OPTARG" ] 2>/dev/null; then
VAL=$OPTARG ;
else
VAL=1 ;
fi
case $arg in
b) rebuild=$VAL ;;
d) dev=$VAL ;;
h) usage ; exit ;;
s) stable=$VAL ;;
\?) echo "Invalid option -$OPTARG" >&2 ;;
esac
done
ENV=`if [ $dev -eq 1 ] ; then echo 'dev' ; else echo 'production' ; fi`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment