Skip to content

Instantly share code, notes, and snippets.

@DanielViglione
Last active April 20, 2021 15:58
Show Gist options
  • Save DanielViglione/3d9c66df42162896eed2981197a1ee79 to your computer and use it in GitHub Desktop.
Save DanielViglione/3d9c66df42162896eed2981197a1ee79 to your computer and use it in GitHub Desktop.
public gist for bash.
#!/bin/bash
SUBDOMAIN_SUFFIX=$1
REGION=$2
env=$3
if [[ $env == "dev" ]]
then
# Get list of directories modified in current commit.
LIST_OF_DIRS=$(git diff --dirstat=files,0 HEAD~2 | awk '{print $2}' | cut -d '/' -f 1 | uniq)
CURR_DIR=$(echo $(pwd))
for i in $LIST_OF_DIRS
do
cd $CURR_DIR
cd $i
echo "current dir is $(pwd)"
echo $SUBDOMAIN_SUFFIX
npm install
npm run build
ls -la
S3_BUCKET=dev-$i-$SUBDOMAIN_SUFFIX
aws s3 cp build s3://$S3_BUCKET/ --recursive --region $REGION
done
else
# Get list of directories modified in current commit.
LIST_OF_DIRS=$(git diff --dirstat=files,0 HEAD~2 | awk '{print $2}' | cut -d '/' -f 1 | uniq)
CURR_DIR=$(echo $(pwd))
for i in $LIST_OF_DIRS
do
cd $CURR_DIR
cd $i
echo "current dir is $(pwd)"
echo $SUBDOMAIN_SUFFIX
npm install
npm run build
ls -la
S3_BUCKET=$i-$SUBDOMAIN_SUFFIX
aws s3 cp build s3://$S3_BUCKET/ --recursive --region $REGION
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment