diff options
author | Aspen Smith <root@gws.fyi> | 2023-11-06T21·02-0500 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-11-06T21·17+0000 |
commit | edea6dadddbc8d8484d5790dd3aed787630b8258 (patch) | |
tree | 5ecdf220df5a91cdf9bb4bbe51ac7cfc519e6b4f /users/grfn/web/default.nix | |
parent | 97b63a84685442aebc859d1eec6efc094a810119 (diff) |
feat(users/grfn/web): Purge cloudflare cache on deploy r/6969
Change-Id: Iebaff500bc7bbb92ff4344f185a3b446f9ce9eb9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9975 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/web/default.nix')
-rw-r--r-- | users/grfn/web/default.nix | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/users/grfn/web/default.nix b/users/grfn/web/default.nix index 5ab3614d7902..580e1c8cd1cd 100644 --- a/users/grfn/web/default.nix +++ b/users/grfn/web/default.nix @@ -28,10 +28,34 @@ let cp ${keys} $out/keys ''; + purge-cf = writeShellApplication { + name = "purge-cf.sh"; + runtimeInputs = [ httpie jq pass ]; + text = '' + cfapi() { + http \ + "https://api.cloudflare.com/client/v4/$1" \ + X-Auth-Email:root@gws.fyi \ + "X-Auth-Key: $(pass cloudflare-api-key)" \ + "''${@:2}" + } + + zone_id=$( + cfapi zones \ + | jq -r '.result[] | select(.name == "gws.fyi") | .id' + ) + + cfapi "zones/$zone_id/purge_cache" purge_everything:=true + ''; + }; in -(writeShellScript "deploy.sh" '' - ${awscli2}/bin/aws --profile personal s3 sync ${website}/ ${bucket} - echo "Deployed to http://gws.fyi" -'') // { - inherit website site; +(writeShellApplication { + name = "deploy.sh"; + runtimeInputs = [ awscli2 ]; + text = '' + aws --profile personal s3 sync ${website}/ ${bucket} + echo "Deployed to http://gws.fyi" + ''; +}).overrideAttrs { + passthru = { inherit website site purge-cf; }; } |