-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh-actions.ncl
88 lines (84 loc) · 2.35 KB
/
gh-actions.ncl
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
let gha = import "./out/GitHub Workflow.ncl" in
let setup = [
{
name = "Checkout",
uses = "actions/checkout@v2",
},
{
name = "Install Nix",
uses = "cachix/install-nix-action@v26",
with.extra_nix_config = "accept-flake-config = true",
},
{
uses = "cachix/cachix-action@v14",
with.name = "nickel-schemastore",
with.authToken = "${{ secrets.CACHIX_AUTH_TOKEN }}",
},
]
in
{
update-flake-lock = {
jobs.update-flake-lock = {
runs-on = "ubuntu-latest",
steps =
setup
@ [
{
name = "Update flake.lock",
uses = "DeterminateSystems/update-flake-lock@v21",
}
],
},
on.schedule = [{ cron = "0 0 * * 0" }],
},
update-schemas = {
jobs.test = {
permissions.pull-requests = "write",
permissions.contents = "write",
runs-on = "ubuntu-latest",
steps =
setup
@ [
{
env.GH_TOKEN = "${{ github.token }}",
name = "Update the schemas from upstream",
run = m%"
nix develop --command python3 ./extract-schemas.py
if ! git diff --exit-code; then
BRANCH_NAME=update-schemas-from-$GITHUB_RUN_ID
git checkout -b "$BRANCH_NAME"
git add .
git config user.name "Schemas update bot"
git config user.email "[email protected]"
git commit --message="Re-generate the schema files"
git push origin "$BRANCH_NAME"
nix run --inputs-from . nixpkgs\#gh -- pr create \
--head "$BRANCH_NAME" \
--title "Re-generate the schema files" \
--body "Automated update from $GITHUB_RUN_ID"
fi
"%,
}
],
},
on.schedule = [{ cron = "0 0 * * 0" }],
on.workflow_dispatch = {},
},
check-up-to-date-generated-files = {
on.push = {},
jobs.check-up-to-date-generated-files = {
runs-on = "ubuntu-latest",
steps =
setup
@ [
{
name = "Check that the file generated by Organist are up-to-date",
run = m%"
nix run .#regenerate-files -L
git diff --exit-code && echo "All files up-to-date ✅"
"%
}
],
},
},
} | { _ | gha }