summaryrefslogtreecommitdiffstats
path: root/.circleci/deploy.pl
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-08-07 19:35:47 +0200
committerGitHub <noreply@github.com>2017-08-07 19:35:47 +0200
commit4663032035039cc642db9b3f82b289418d02c430 (patch)
tree553648b0cc683692cabcbc9ae45ef46f8af3b759 /.circleci/deploy.pl
parent28a1de6319da8b481b9b5ec08f070bce65e17bb3 (diff)
downloadbugzilla-4663032035039cc642db9b3f82b289418d02c430.tar.gz
bugzilla-4663032035039cc642db9b3f82b289418d02c430.tar.xz
Bug 1383355 - Migrate CI tests from taskcluster to CircleCI
Diffstat (limited to '.circleci/deploy.pl')
-rwxr-xr-x.circleci/deploy.pl52
1 files changed, 52 insertions, 0 deletions
diff --git a/.circleci/deploy.pl b/.circleci/deploy.pl
new file mode 100755
index 000000000..391b9b660
--- /dev/null
+++ b/.circleci/deploy.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+use 5.10.1;
+use strict;
+use warnings;
+
+my ($repo, $user, $pass) = check_env(qw(DOCKERHUB_REPO DOCKER_USER DOCKER_PASS));
+run("docker", "login", "-u", $user, "-p", $pass);
+
+my @docker_tags = ($ENV{CIRCLE_SHA1});
+
+if ($ENV{CIRCLE_TAG}) {
+ push @docker_tags, $ENV{CIRCLE_TAG};
+}
+elsif ($ENV{CIRCLE_BRANCH}) {
+ if ($ENV{CIRCLE_BRANCH} eq 'master') {
+ push @docker_tags, 'latest';
+ }
+ else {
+ push @docker_tags, $ENV{CIRCLE_BRANCH};
+ }
+}
+
+say "Pushing tags...";
+say " $_" for @docker_tags;
+foreach my $tag (@docker_tags) {
+ run("docker", "tag", "bmo", "$repo:$tag");
+ run("docker", "push", "$repo:$tag");
+}
+
+sub run {
+ my (@cmd) = @_;
+ my $rv = system(@cmd);
+ exit 1 if $rv != 0;
+}
+
+sub check_env {
+ my (@missing, @found);
+ foreach my $name (@_) {
+ push @missing, $name unless $ENV{$name};
+ push @found, $ENV{$name};
+ }
+
+ if (@missing) {
+ warn "Missing environmental variables: ", join(", ", @missing), "\n";
+ exit;
+ }
+ return @found;
+}
+
+
+
+