about summary refs log tree commit diff
path: root/ops/github
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-10-04 17:50:11 -0700
committerFranck Cuny <franck@fcuny.net>2022-10-04 17:50:11 -0700
commit255538c32e10e5dac29cac39a28ce499227f067f (patch)
tree2ece731263ebe6fc40e37a32f8ad5af969d3aed2 /ops/github
parentref(tools/ssh-key-to-forge): replaced by gh-ssh-keys (diff)
downloadworld-255538c32e10e5dac29cac39a28ce499227f067f.tar.gz
ops(terraform): individual actions for init/plan/apply
Don't do all of these actions together, instead provide helpers for both
init, plan, and apply.
Diffstat (limited to 'ops/github')
-rw-r--r--ops/github/README.org4
-rw-r--r--ops/github/default.nix29
2 files changed, 31 insertions, 2 deletions
diff --git a/ops/github/README.org b/ops/github/README.org
index 86c664a..5906fbd 100644
--- a/ops/github/README.org
+++ b/ops/github/README.org
@@ -5,8 +5,8 @@ This terraform configuration is to manage my GitHub configuration (repositories,
 There's nothing special regarding how to use this repository.
 
 #+begin_src sh
-GITHUB_TOKEN=(pass api/github/terraform) terraform plan
-GITHUB_TOKEN=(pass api/github/terraform) terraform apply
+GITHUB_TOKEN=(pass api/github/terraform) nix run .#ops.github.plan
+GITHUB_TOKEN=(pass api/github/terraform) nix run .#ops.github.init
 #+end_src
 
 * Credentials
diff --git a/ops/github/default.nix b/ops/github/default.nix
new file mode 100644
index 0000000..a36aa12
--- /dev/null
+++ b/ops/github/default.nix
@@ -0,0 +1,29 @@
+{ pkgs }:
+let
+  terraform = pkgs.terraform.withPlugins (p: [
+    p.google
+    p.github
+  ]);
+in
+pkgs.stdenv.mkDerivation rec {
+  name = "tf-github";
+  src = ./.;
+
+  init = pkgs.writeShellScriptBin "tf-github-init" ''
+    set -ueo pipefail
+    cd $(git rev-parse --show-toplevel)/ops/github
+    ${terraform}/bin/terraform init
+  '';
+
+  plan = pkgs.writeShellScriptBin "tf-github-plan" ''
+    set -ueo pipefail
+    cd $(git rev-parse --show-toplevel)/ops/github
+    ${terraform}/bin/terraform plan
+  '';
+
+  apply = pkgs.writeShellScriptBin "tf-github-apply" ''
+    set -ueo pipefail
+    cd $(git rev-parse --show-toplevel)/ops/github
+    ${terraform}/bin/terraform apply
+  '';
+}