-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh-actions-options.nix
144 lines (143 loc) · 5.14 KB
/
gh-actions-options.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{ lib, ...}:
let
cachixdoc = "https://nix.dev/tutorials/continuous-integration-github-actions#setting-up-github-actions";
cache = lib.types.submodule {
options.name = lib.mkOption {
type = lib.types.nonEmptyStr;
default = null;
example = "MyCACHIXCacheName";
description = ''
Name of your cache in [CACHIX](${cachixdoc})
'';
};
options.key-name = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "CACHIX_SIGNING_KEY";
description = ''
Name of GH Secret with [CACHIX SIGNING KEY](${cachixdoc})
'';
};
options.token-name = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default = "CACHIX_AUTH_TOKEN";
example = "CACHIX_AUTH_TOKEN";
description = ''
Name of GH Secret with [CACHIX AUTH TOKEN](${cachixdoc})
'';
};
};
workflow = lib.types.submodule {
options.enable = lib.mkEnableOption "Github Actions CI-CD";
options.cache = lib.mkOption {
type = lib.types.nullOr cache;
default = null;
description = ''
[CACHIX](${cachixdoc}) binary cache configuration
'';
example.name = "MyCACHIXCacheName";
example.key-name = "CACHIX_SIGNING_KEY";
};
options.ssh-secret-name = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "GH_ACTIONS_SSH_KEY";
description = ''
Name of GH Secret with PRIVATE SSH KEY
for more advanced usage try ssh option
'';
};
options.ssh = lib.mkOption {
type = lib.types.nullOr (lib.types.attrsOf lib.types.str);
default = null;
description = ''
https://github.com/marketplace/actions/install-ssh-key
Config for ssh installation
There are two reasons to set it
1. our deploy runs in ssh
2. we have some private git repository
In this last case we should add your public key to some user with repository access (in github) or to our private server.
'';
example.key = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
options.env = lib.mkOption {
description = "env vars for steps";
default = {};
type = lib.types.submodule {
options.pre-build = lib.mkOption {
default = {};
description = ''Env variable used by steps'';
type = lib.types.attrsOf lib.types.str;
example.GIPHY_TOKEN = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
options.build = lib.mkOption {
default = {};
description = ''Env variable used by steps'';
type = lib.types.attrsOf lib.types.str;
example.GIPHY_TOKEN = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
options.test = lib.mkOption {
default = {};
description = ''Env variable used by steps'';
type = lib.types.attrsOf lib.types.str;
example.GIPHY_TOKEN = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
options.deploy = lib.mkOption {
default = {};
description = ''Env variable used by steps'';
type = lib.types.attrsOf lib.types.str;
example.GIPHY_TOKEN = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
options.post-deploy = lib.mkOption {
default = {};
description = ''Env variable used by steps'';
type = lib.types.attrsOf lib.types.str;
example.GIPHY_TOKEN = ''${"$"}{{ secret.GH_ACTIONS_SSH_KEY }}'';
};
};
};
options.on = lib.mkOption {
default.push.branches = ["master"];
example.push.branches = ["master"];
description = "When this build should be triggered";
type = lib.types.attrsOf lib.types.anything;
};
options.pre-build = lib.mkOption {
default = null;
description = "Command to run before build";
example = "npm i";
type = lib.types.nullOr lib.types.nonEmptyStr;
};
options.build = lib.mkOption {
default = null;
description = "Command to run as build step";
example = "npm run build";
type = lib.types.nullOr lib.types.nonEmptyStr;
};
options.test = lib.mkOption {
default = null;
description = "Command to run as test step";
example = "npm test";
type = lib.types.nullOr lib.types.nonEmptyStr;
};
options.deploy = lib.mkOption {
default = null;
description = "Command to run as deploy step";
example = "aws s3 sync ./build s3://my-bucket";
type = lib.types.nullOr lib.types.nonEmptyStr;
};
options.post-deploy = lib.mkOption {
default = null;
description = "Command that run after deploy";
example = "echo Im done";
type = lib.types.nullOr lib.types.nonEmptyStr;
};
};
in
{
options.gh-actions = lib.mkOption {
default = {};
description = "Configure your github actions CI/CD";
type = lib.types.attrsOf workflow;
};
}