Skip to content

Commit

Permalink
branch-dependent deploy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaba committed Aug 29, 2018
1 parent 0a43c98 commit ba6fae9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ CURL = curl
GIT = git
PERL = ./perl

updatenightly: local/bin/pmbp.pl build
updatenightly: local/bin/pmbp.pl clean-update build
$(GIT) add ciconfig
REMOVE_UNUSED=1 RUN_GIT=1 perl ciconfig
$(CURL) -s -S -L -f https://gist.githubusercontent.com/wakaba/34a71d3137a52abb562d/raw/gistfile1.txt | sh
$(GIT) add modules t_deps/modules
perl local/bin/pmbp.pl --update
$(GIT) add config
clean-update:
rm -fr ./ciconfig

## ------ Setup ------

Expand Down
9 changes: 9 additions & 0 deletions ciconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,15 @@ $Options->{'circleci', 'deploy'} = {
},
};

$Options->{'circleci', 'deploy_branch'} = {
set => sub {
my $def = $_[1];
for my $branch (sort { $a cmp $b } keys %$def) {
push @{$_[0]->{_deploy}->{$branch} ||= []}, @{$def->{$branch}};
}
},
};

$Options->{'circleci', 'merger'} = {
set => sub {
return unless $_[1];
Expand Down
9 changes: 9 additions & 0 deletions lib/Main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ $Options->{'circleci', 'deploy'} = {
},
};

$Options->{'circleci', 'deploy_branch'} = {
set => sub {
my $def = $_[1];
for my $branch (sort { $a cmp $b } keys %$def) {
push @{$_[0]->{_deploy}->{$branch} ||= []}, @{$def->{$branch}};
}
},
};

$Options->{'circleci', 'merger'} = {
set => sub {
return unless $_[1];
Expand Down
21 changes: 21 additions & 0 deletions t/main.t
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,27 @@ for (
}},
workflows => {version => 2, build => {jobs => ['build']}},
}}}],
[{circleci => {build => [
{command => ['a', 'b']},
], deploy_branch => {
b1 => ['c'],
b2 => ['d'],
}}} => {'.circleci/config.yml' => {json => {
version => 2,
jobs => {build => {
machine => {enabled => \1},
environment => {CIRCLE_ARTIFACTS => '/tmp/circle-artifacts'},
steps => [
'checkout',
{run => {command => 'mkdir -p $CIRCLE_ARTIFACTS'}},
{run => {command => 'a' . "\n" . 'b'}},
{store_artifacts => {path => '/tmp/circle-artifacts'}},
{deploy => {command => q{if [ "${CIRCLE_BRANCH}" == 'b1' ]; then} . "\x0Atrue\x0A" . 'c' . "\x0Afi"}},
{deploy => {command => q{if [ "${CIRCLE_BRANCH}" == 'b2' ]; then} . "\x0Atrue\x0A" . 'd' . "\x0Afi"}},
],
}},
workflows => {version => 2, build => {jobs => ['build']}},
}}}],
) {
my ($input, $expected) = @$_;
for (qw(.travis.yml circle.yml .circleci/config.yml)) {
Expand Down

0 comments on commit ba6fae9

Please sign in to comment.