infra/effect.nix

32 lines
1.1 KiB
Nix
Raw Normal View History

{ withSystem, ... }:
{
herculesCI = { config, ... }:
let
inherit (config.repo) ref;
in
{
2023-05-19 23:51:43 +10:00
onPush.default.outputs.effects = withSystem "x86_64-linux" ({ hci-effects, pkgs, self', ... }:
{
terraform-deploy =
2023-05-02 18:35:18 +10:00
hci-effects.runIf (pkgs.lib.hasPrefix "refs/heads/gh-readonly-queue/master/" ref)
(hci-effects.mkEffect {
name = "terraform-deploy";
2023-05-19 23:51:43 +10:00
inputs = [ self'.devShells.terraform.nativeBuildInputs ];
src = pkgs.lib.cleanSource ./.;
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)"
pushd terraform
terraform init
terraform validate
2023-05-02 18:35:18 +10:00
terraform apply -auto-approve
'';
});
});
};
}