forked from hercules-ci/hercules-ci-effects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ config, lib, hci-effects, ... }: | ||
let | ||
inherit (lib) mkOption types optionalAttrs; | ||
cfg = config.netlify-deploy; | ||
in | ||
{ | ||
options.netlify-deploy = { | ||
enable = lib.mkEnableOption "On-push deployment to Netlify"; | ||
|
||
siteId = mkOption { | ||
type = (types.nullOr types.str); | ||
default = null; | ||
description = lib.mdDoc '' | ||
An opaque identifier assigned by Netlify to the website you wish to deploy. | ||
See [docs.hercules-ci.com](https://docs.hercules-ci.com/hercules-ci-effects/reference/nix-functions/netlifydeploy/#param-name) on how to get the right siteId for your website from Netlify. | ||
''; | ||
}; | ||
|
||
secretName = mkOption { | ||
type = (types.nullOr types.str); | ||
default = null; | ||
description = lib.mdDoc '' | ||
The secret that will be looked up in [secrets.json](https://docs.hercules-ci.com/hercules-ci-agent/secrets-json). | ||
This secret must hold the `${cfg.secretField}` field, ith a string value that is a Netlify personal access token. | ||
''; | ||
}; | ||
|
||
secretField = mkOption { | ||
type = types.str; | ||
default = "token"; | ||
description = lib.mdDoc "The name of the field inside the `${cfg.secretName}` secret which holds the Netlify personal access token."; | ||
}; | ||
|
||
content = mkOption { | ||
type = (types.nullOr types.str); | ||
default = null; | ||
description = lib.mdDoc '' | ||
Path to the site content, also known as the Publish directory. | ||
This includes files such as netlify.toml, _redirects, and all web resources, like index.html, style sheets, etc. | ||
You will typically put a derivation here. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
''; | ||
}; | ||
|
||
productionDeployment = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = lib.mdDoc "Whether this should be production deployment."; | ||
}; | ||
|
||
extraDeployArgs = mkOption { | ||
type = (types.listOf types.str); | ||
default = [ ]; | ||
description = lib.mdDoc "Extra arguments to pass to the netlify deploy invocation."; | ||
}; | ||
}; | ||
|
||
config = { | ||
herculesCI = optionalAttrs (cfg.enable) { | ||
onPush.default.outputs.effects.netlify-deploy = hci-effects.netlifyDeploy { | ||
}; | ||
}; | ||
|
||
assertions = [ | ||
{ assertion = (cfg.siteId != null); message = "`siteId` must be set."; } | ||
{ assertion = (cfg.secretName != null); message = "`secretName` must be set."; } | ||
{ assertion = (cfg.content != null); message = "`content` must be set."; } | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I wrote a mutable one the other day, for docs.hercules-ci.com. It can be a relative path to something built in a previous phase or hook. (Note to self: hercules-ci#88)