feat(module/workflow): Add a header to the start of generated files
All checks were successful
Run pre-commit on all files / pre-push (push) Successful in 19s
All checks were successful
Run pre-commit on all files / pre-push (push) Successful in 19s
This commit is contained in:
parent
829e83af9c
commit
f2aaa2230c
1 changed files with 35 additions and 9 deletions
|
@ -25,6 +25,7 @@ let
|
|||
attrsOf
|
||||
bool
|
||||
enum
|
||||
lines
|
||||
path
|
||||
str
|
||||
;
|
||||
|
@ -34,7 +35,13 @@ let
|
|||
cfg = config;
|
||||
|
||||
generate =
|
||||
name: value:
|
||||
name:
|
||||
{
|
||||
|
||||
buildCheck,
|
||||
rootSrc,
|
||||
value,
|
||||
}:
|
||||
runCommand "${name}.yaml"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
|
@ -43,21 +50,29 @@ let
|
|||
];
|
||||
|
||||
value = builtins.toJSON value;
|
||||
passAsFile = [ "value" ];
|
||||
inherit (cfg) header;
|
||||
passAsFile = [
|
||||
"header"
|
||||
"value"
|
||||
];
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
''
|
||||
json2yaml "$valuePath" "$out"
|
||||
|
||||
# Check that the workflow is valid
|
||||
cd "${cfg.rootSrc}" && action-validator "$out"
|
||||
'';
|
||||
json2yaml "$valuePath" out
|
||||
cat "$headerPath" out > "$out"
|
||||
''
|
||||
+ (optionalString buildCheck ''
|
||||
# Check that the workflow is valid
|
||||
cd "${rootSrc}" && action-validator "$out"
|
||||
'');
|
||||
|
||||
install =
|
||||
name: value:
|
||||
let
|
||||
result =
|
||||
if cfg.buildCheck then generate name value else (pkgs.formats.yaml { }).generate name value;
|
||||
result = generate name {
|
||||
inherit value;
|
||||
inherit (cfg) buildCheck rootSrc;
|
||||
};
|
||||
path = ".${cfg.platform}/workflows/${name}.yaml";
|
||||
in
|
||||
''
|
||||
|
@ -121,6 +136,17 @@ in
|
|||
It introduces a dependency on the `rootSrc` directory.
|
||||
'';
|
||||
};
|
||||
|
||||
header = mkOption {
|
||||
type = lines;
|
||||
default = ''
|
||||
###
|
||||
# This file was automatically generated with nix-actions.
|
||||
'';
|
||||
description = ''
|
||||
Text header to prepend to the generated workflow YAML file.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
|
Loading…
Add table
Reference in a new issue