Skip to content

Commit 7bacd60

Browse files
committed
refactor(ci): modularize github actions configuration
Splits the monolithic actions.nix into a directory structure for better organization and reusability. Introduces a new workflow for automatic flake.lock updates.
1 parent 8bd37af commit 7bacd60

File tree

4 files changed

+107
-70
lines changed

4 files changed

+107
-70
lines changed

flake/actions.nix

Lines changed: 0 additions & 70 deletions
This file was deleted.

flake/actions/default.nix

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
inputs,
3+
customLib,
4+
...
5+
}: {
6+
imports =
7+
(customLib.scanPaths ./.)
8+
++ [
9+
inputs.actions-nix.flakeModules.default
10+
];
11+
12+
_module.args = {
13+
common-on = rec {
14+
push = {
15+
branches = ["main"];
16+
paths = [
17+
"flake.nix"
18+
"flake.lock"
19+
"flake/**"
20+
];
21+
};
22+
pull_request = push;
23+
workflow_dispatch = {};
24+
};
25+
common-permissions = {
26+
contents = "write";
27+
id-token = "write";
28+
};
29+
common-actions = [
30+
{
31+
name = "Checkout repo";
32+
uses = "actions/checkout@main";
33+
"with" = {
34+
fetch-depth = 1;
35+
};
36+
}
37+
inputs.actions-nix.lib.steps.DeterminateSystemsNixInstallerAction
38+
{
39+
name = "Magic Nix Cache(Use GitHub Actions Cache)";
40+
uses = "DeterminateSystems/magic-nix-cache-action@main";
41+
}
42+
];
43+
};
44+
45+
flake.actions-nix = {
46+
pre-commit.enable = true;
47+
defaultValues = {
48+
jobs = {
49+
runs-on = "ubuntu-latest";
50+
timeout-minutes = 30;
51+
};
52+
};
53+
};
54+
}

flake/actions/flake-check.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
common-on,
3+
common-permissions,
4+
common-actions,
5+
...
6+
}: {
7+
flake.actions-nix.workflows.".github/workflows/flake-check.yml" = {
8+
on = common-on;
9+
jobs.checking-flake = {
10+
permissions = common-permissions;
11+
steps =
12+
common-actions
13+
++ [
14+
{
15+
name = "Run nix flake check";
16+
run = "nix -vL flake check --impure --all-systems --no-build";
17+
}
18+
];
19+
};
20+
};
21+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
common-permissions,
3+
common-actions,
4+
...
5+
}: {
6+
flake.actions-nix.workflows.".github/workflows/flake-lock-update.yml" = {
7+
on = {
8+
workflow_dispatch = {};
9+
schedule = [
10+
{
11+
cron = "0 0 * * 0"; # Every Sunday at midnight
12+
}
13+
];
14+
};
15+
jobs.locking-flake = {
16+
permissions =
17+
common-permissions
18+
// {
19+
issues = "write";
20+
pull-requests = "write";
21+
};
22+
steps =
23+
common-actions
24+
++ [
25+
{
26+
name = "Update flake.lock";
27+
uses = "DeterminateSystems/update-flake-lock@main";
28+
}
29+
];
30+
};
31+
};
32+
}

0 commit comments

Comments
 (0)