Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to auto checkout build branches with git post-receive? #1501

Closed
kevinquillen opened this issue May 12, 2017 · 1 comment
Closed

How to auto checkout build branches with git post-receive? #1501

kevinquillen opened this issue May 12, 2017 · 1 comment

Comments

@kevinquillen
Copy link

I am using TravisCI to build and deploy to a remote repo.

When Travis calls the blt deploy command and commits the artifact to develop-build and pushes, on the remote server I want to capture this event in a post-receive hook and check out to the appropriate working directory.

Here is the post-receive hook:

#!/bin/sh

while read oldrev newrev ref
do
  branch=`echo $ref | cut -d/ -f3-`

  if [ "develop-build" == "$branch" ]; then
    sudo git --work-tree=/data/websites/dev.mysite.org/web --git-dir=/var/repos/mysite-org.git checkout -f $branch
    sudo chown -Rf www-data:www-data /data/websites/dev.mysite.org/web
  fi
done

While I can see the change with git log -g, it doesn't appear that the checkout happens.

Is there something unique to the deploy/commit of the artifact branches that prevent this from working?

@kevinquillen
Copy link
Author

Welp, looks like this was the difference between specifying #!/bin/bash vs #!/bin/sh. Syntax differences.

See: http://stackoverflow.com/questions/3411048/unexpected-operator-in-shell-programming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant