Skip to content

Instantly share code, notes, and snippets.

@Adirelle
Last active April 28, 2017 04:33
Show Gist options
  • Save Adirelle/a72138eabff4006f81d5 to your computer and use it in GitHub Desktop.
Save Adirelle/a72138eabff4006f81d5 to your computer and use it in GitHub Desktop.
Post-commit hook to testing local PHPCI
#!/bin/bash
#
# Copy this script to .git/hooks/post-commit.
# Make it executable.
# Setup a project with "remote repository" (not local !) that points your PHPCI root.
# And finally, edit the two first lines according to your local installation.
PHPCI_URL=http://my.phpci.url
PROJECT_ID="PHPCI projet identifier"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
IFS=^ INFO=($(git log -1 HEAD --format="%H^%ce^%s"))
echo -n "PHPCI webhook: "
curl \
--data-urlencode branch="$BRANCH" \
--data-urlencode commit="${INFO[0]}" \
--data-urlencode committer="${INFO[1]}" \
--data-urlencode message="${INFO[2]}" \
"$PHPCI_URL/webhook/git/$PROJECT_ID"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment