-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgithub.nix
61 lines (59 loc) · 1.55 KB
/
github.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
# This module provides some tools that interact with GitHub
final: prev:
let
inherit (final) _ pog;
in
rec {
github_tags = pog {
name = "github_tags";
description = "a nice wrapper for getting github tags for a repo!";
flags = [
{
name = "latest";
description = "fetch only the latest tag";
bool = true;
}
_.flags.github.owner
_.flags.github.repo
];
script =
let
_curl = "${_.curl} -Ls";
_jq = "${final.jq}/bin/jq -r";
in
helpers: ''
api_url="https://api.github.com/repos/$owner/$repo"
if ${helpers.flag "latest"}; then
${_curl} "$api_url/releases/latest" | ${_jq} '.tag_name'
else
${_curl} "$api_url/tags" | ${_jq} '.[].name'
fi
'';
};
github_actions = pog {
name = "github_actions";
description = "a nice wrapper for running github actions locally!";
flags = [
{
name = "arch";
default = "amd64";
description = "the underlying arch to use in the docker images [amd64/arm64]";
}
{
name = "flags";
default = "";
description = "additional flags to pass to act";
}
];
script = ''
# shellcheck disable=SC2155
export DOCKER_HOST="$(${prev.docker-client}/bin/docker context inspect --format '{{.Endpoints.docker.Host}}')"
# shellcheck disable=SC2086
${prev.act}/bin/act --container-architecture "linux/$arch" -r --rm $flags
'';
};
github_pog_scripts = [
github_tags
github_actions
];
}