Last active
January 19, 2018 01:37
-
-
Save matt-bailey/bfdaaa290954e1a23f2f to your computer and use it in GitHub Desktop.
Example front-end workflow post-merge Git Hook
This file contains 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
#/usr/bin/env bash | |
# git hook to run a command after `git merge` or `git pull` | |
# Check for changed files | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
check_run() { | |
echo "$changed_files" | grep --quiet "$1" && eval "$2" | |
} | |
# `npm install` and `npm prune` if the `package.json` file gets changed | |
echo "--- Updating Node packages..." | |
check_run package.json "(cd theme; npm install && npm prune)" | |
echo -e "\xE2\x9C\x93 Node packages updated" | |
# `bower install` and `bower prune` if the `bower.json` file gets changed | |
echo "--- Updating Bower components..." | |
check_run bower.json "(cd themes; bower install --allow-root && bower prune --allow-root)" | |
echo -e "\xE2\x9C\x93 Bower components updated" | |
# Run the build process `grunt` | |
echo "--- Running the build process..." | |
(cd theme; grunt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment