Last active
March 12, 2020 21:14
-
-
Save isitgeorge/577ea7a5c32241bf9a13d05f304ba168 to your computer and use it in GitHub Desktop.
Determine which services to deploy based on modified Git paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
services=() | |
diff="$(git diff --name-status HEAD~1)" | |
for dir in * | |
do | |
if [[ $dir =~ "service-" ]] && [[ $diff =~ $dir ]]; then | |
services=(${services[@]} $dir) | |
fi | |
done | |
if [ ${#services[@]} -eq 0 ]; then | |
printf "%s\n%s\n" "########## Nothing to deploy. Skipping..." | |
else | |
printf "%s\n%s" "########## Services with changes to be deployed:" | |
printf '%s\n' "${services[@]}" | |
for i in "${services[@]}" | |
do | |
cd $i/ | |
printf "\n%s\n" "########## Deploying $i from $(pwd)" | |
(serverless deploy) || { printf "\n%s\n" "########## Deployment failed for $i, check logs above" ; exit 1; } | |
cd .. | |
done || exit 1 | |
printf "\n%s\n\n" "########## Deployed successfully" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment