-
-
Save briceburg/9e376a3abf3d9f299b35 to your computer and use it in GitHub Desktop.
Execute a hook in './hooks/<service>/<action>' when that event is received
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 | |
set -e | |
function handle_event() { | |
local entry="$1" | |
local action=$(echo $entry | jq -r '.action') | |
local service=$(echo $entry | jq -r '.service') | |
local hook="./hooks/$service/$action" | |
if [ -x "$hook" ]; then | |
"$hook" "$entry" | |
fi | |
} | |
docker-compose events --json | ( | |
while read line; do | |
handle_event "$line" | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment