Skip to content

Instantly share code, notes, and snippets.

@restuu
Created April 21, 2020 13:27
Show Gist options
  • Save restuu/859f101213acf2be2171dbeacd080508 to your computer and use it in GitHub Desktop.
Save restuu/859f101213acf2be2171dbeacd080508 to your computer and use it in GitHub Desktop.
Bash script to deploy based on git diff
#!/bin/bash
set -e
# get package directories based on diff change from last 5 commits
list=$(git diff --name-only HEAD~5..HEAD . | grep -o "packages/\w*" | uniq)
# store root dir
pwd=$PWD
# deploy each package
# TODO: Deploy with timeout
# TODO: Build pipeline that call this bash script
for d in $list; do
cd "${pwd}/${d}" && npm run deploy || echo "[ERROR] deploying $d"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment