infra/dev/effect.nix

29 lines
1 KiB
Nix
Raw Normal View History

2023-06-08 11:39:57 +10:00
{ self, withSystem, ... }:
{
herculesCI = { config, ... }:
2023-05-24 16:02:18 +10:00
withSystem "x86_64-linux" ({ hci-effects, pkgs, self', ... }:
{
onPush.default.outputs.effects = {
terraform-deploy = hci-effects.runIf (pkgs.lib.hasPrefix "refs/heads/gh-readonly-queue/master/" config.repo.ref)
(hci-effects.mkEffect {
name = "terraform-deploy";
inputs = [ self'.devShells.terraform.nativeBuildInputs ];
2023-06-08 11:39:57 +10:00
src = toString self;
2023-05-24 16:02:18 +10:00
secretsMap.tf-secrets = "tf-secrets";
effectScript = ''
export TF_IN_AUTOMATION=1
export TF_INPUT=0
export SOPS_AGE_KEY="$(readSecretString tf-secrets .SOPS_AGE_KEY)"
export TF_TOKEN_app_terraform_io="$(readSecretString tf-secrets .TF_TOKEN_app_terraform_io)"
2023-05-24 16:02:18 +10:00
pushd terraform
terraform init
terraform validate
terraform apply -auto-approve
'';
});
};
}
);
}