Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
Fix things and shiz
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyChatha committed Mar 10, 2020
1 parent 2c953b6 commit eccf043
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions source/aim/deploy/commands.d
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ final class AimDeployTriggerCheck : BaseCommand
private IAimCliConfig!AimDeployConfig _deployConf;
private ICommandLineInterface _cli;

@CommandNamedArg("no-post-deploy", "Don't trigger post deployments for triggers. Useful for debugging.")
Nullable!bool noPostDeploy;

this(IAimDeployTriggerFactory factory, IAimCliConfig!AimDeployConfig deployConf, ICommandLineInterface cli)
{
this._triggerFactory = factory;
Expand Down Expand Up @@ -231,9 +234,12 @@ final class AimDeployTriggerCheck : BaseCommand
status = this._cli.parseAndExecute(["deploy", "trigger"], IgnoreFirstArg.no);
else
Shell.verboseLogfln("No triggers were successful");

foreach(trigger; successfulTriggers)
trigger.onPostDeploy(status == 0);

if(!this.noPostDeploy.get(false))
{
foreach(trigger; successfulTriggers)
trigger.onPostDeploy(status == 0);
}

return status;
}
Expand Down
8 changes: 4 additions & 4 deletions source/aim/deploy/triggers.d
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class GithubAimDeployTrigger : IAimDeployTrigger
this._githubConf.edit((scope ref conf)
{
if(conf.lastDeploymentTime.length == 0)
conf.lastDeploymentTime = Clock.currTime.toISOString();
conf.lastDeploymentTime = (new SysTime(0)).toISOExtString();
});
}

Expand Down Expand Up @@ -123,12 +123,12 @@ final class GithubAimDeployTrigger : IAimDeployTrigger
).readJson();
Shell.verboseLogfln("Response: %s", response.toPrettyString());

auto lastDeployTime = SysTime.fromISOString(this._githubConf.value.lastDeploymentTime);
auto lastDeployTime = SysTime.fromISOExtString(this._githubConf.value.lastDeploymentTime);
auto nodes = response["data"]["repository"]["deployments"]["nodes"];
auto firstPendingProduction = nodes.byValue
.filter!(v => v["environment"].to!string == "production" // TODO: This should be a config option.
&& v["state"].to!string == "PENDING" // TODO: Arguably this too, but it's less important.
&& SysTime.fromISOExtString(v["createdAt"].to!string()) > lastDeployTime
&& SysTime.fromISOExtString(v["createdAt"].to!string()[0..$-1] ~ ".0000000" ~ "Z") > lastDeployTime
);

if(firstPendingProduction.empty)
Expand All @@ -145,7 +145,7 @@ final class GithubAimDeployTrigger : IAimDeployTrigger
this._githubConf.edit((scope ref conf)
{
conf.deploymentId = databaseId; // So onPostDeploy knows what ID to use.
conf.lastDeploymentTime = deployment["createdAt"].to!string();
conf.lastDeploymentTime = deployment["createdAt"].to!string()[0..$-1] ~ ".0000000" ~ "Z";
});

// Find the ref, as that's being used as the image tag.
Expand Down

0 comments on commit eccf043

Please sign in to comment.