Skip to content

Instantly share code, notes, and snippets.

@JannieT
Last active August 29, 2015 14:10
Show Gist options
  • Save JannieT/804262364d8124704d30 to your computer and use it in GitHub Desktop.
Save JannieT/804262364d8124704d30 to your computer and use it in GitHub Desktop.
Mercurial deployment script
[ui]
username = Jannie Theunissen [email protected]
ssh = ssh -C
// /home/www/devnavigator.co.za/laravel/app/models/Deploy.php
public function runBash()
{
$this->log('Attempting deployment...');
$output = array();
try
{
/* Make sure we're in the right directory */
chdir($this->directory);
/* run the bash script */
exec("sh deploy.sh", $output);
$this->log(implode('|', $output));
$this->log('Deployment done.');
}
catch (Exception $e)
{
$this->log($e, 'ERROR');
}
}
#!/bin/bash
echo "fetching changes from the remote repository ..."
cd /home/www/devnavigator.co.za/laravel
hg revert --all --no-backup
## the following command fails, because mercurial doesn't know
## the user credentials to connect to the remote repo
hg pull
hg update master
echo "done"
## I can tell Mercurial which user to use by putting a ~/.hgrc config file in the user's home folder
## Problem is, apache currently doesn't run as a user with a home folder
Here's a log dump from /home/www/[redacted]/deployments.log
It can be viewed at
2014-11-28 10:00:55+02:00 --- INFO: Attempting deployment...
2014-11-28 10:00:55+02:00 --- INFO: fetching changes from the remote repository ...|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|abort: repository default not found!|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|not trusting file /home/www/<redacted>/laravel/.hg/hgrc from untrusted user jannie, group www|0 files updated, 0 files merged, 0 files removed, 0 files unresolved|done
2014-11-28 10:00:55+02:00 --- INFO: Deployment done.
Which shows the script didn't pull in any changes. If I ssh in and run the deploy as a user, the changes are pulled:
jannie@devserver:~$ deploy
fetching changes from the remote repository ...
pulling from ssh://[email protected]/beenavigator/web-app
searching for changes
adding changesets
adding manifests
adding file changes
added 26 changesets with 82 changes to 36 files
(run 'hg update' to get a working copy)
35 files updated, 0 files merged, 2 files removed, 0 files unresolved
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment