Skip to content

Instantly share code, notes, and snippets.

@gigablah
Created August 22, 2012 14:47
Show Gist options
  • Save gigablah/3426334 to your computer and use it in GitHub Desktop.
Save gigablah/3426334 to your computer and use it in GitHub Desktop.
Staging deployment using Rex
use strict;
use warnings;
use Rex::Transaction;
use Rex::Apache::Build;
use Rex::Apache::Deploy "Symlink";
user "vgmdb";
private_key "/var/lib/jenkins/.ssh/id_rsa";
public_key "/var/lib/jenkins/.ssh/id_rsa.pub";
group frontend => "slave.vgmdb.org";
deploy_to "/home/vgmdb/deploy";
document_root "/home/vgmdb/www";
generate_deploy_directory sub {
my ($file) = @_;
$file =~ m/-([^\.]+)\.tar\.gz$/;
return $1;
};
get_version_from "VERSION", qr{(.*)};
task "build", sub {
run "git log --pretty=format:'%h' -n 1 > VERSION";
build "vgmdb",
exclude => [".git", ".gitignore"];
};
task "deploy", group => "frontend", sub {
my $old_live = get_live_version;
on_rollback {
say "Rolling back to $old_live\n";
switch_to_version($old_live);
};
deploy "vgmdb";
needs "composer";
};
task "composer", group => "frontend", sub {
run "cd /home/vgmdb/www; composer.phar update;";
};
task "jenkins", sub {
transaction {
do_task [ qw/build deploy/ ];
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment