Skip to content

Commit 15dc64c

Browse files
authored
feat: static generated library (#2)
* feat: static generated library * fix: depluralize steps * fix: reduce levels * fix: bring back container * fmt * fix: remove doc-utils dependency * fix: reduce level in generated lib
1 parent 3cfd37d commit 15dc64c

17 files changed

+6923
-566
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
vendor
21
jsonnetfile.lock.json
2+
vendor

Makefile

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
generate:
2-
jsonnet -m gen -S -J vendor main.libsonnet | xargs -n 1 -- jsonnetfmt --no-use-implicit-plus -i
3-
1+
JSONNET_BIN ?= jsonnet
2+
3+
jsonnetfile.json:
4+
jb init
5+
6+
vendor jsonnetfile.lock.json: jsonnetfile.json
7+
jb install
8+
9+
.PHONY: test
10+
test: vendor jsonnetfile.lock.json
11+
@cd test/ && make test
12+
13+
.PHONY: fmt
14+
fmt:
15+
@find . \
16+
-path './.git' -prune \
17+
-o -name 'vendor' -prune \
18+
-o -name '*.libsonnet' -print \
19+
-o -name '*.jsonnet' -print \
20+
| xargs -n 1 -- jsonnetfmt --no-use-implicit-plus -i
21+
22+
.PHONY: docs
23+
docs: jsonnetfile.json
24+
@rm -rf docs/
25+
@$(JSONNET_BIN) \
26+
-J generator/vendor \
27+
-S -c -m docs \
28+
-e '(import "github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet").render(import "main.libsonnet")'
29+
30+
.PHONY: generate
31+
generate: jsonnetfile.json
32+
jsonnet -J generator/vendor -S generator/generate.jsonnet | jsonnetfmt - > raw.libsonnet

docs/README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
# github-actions-libsonnet
22

3-
Jsonnet library for github-actions-libsonnet
3+
Jsonnet library to create GitHub actions workflows.
4+
## Install
45

5-
> [!CAUTION]
6-
> Incomplete library, very experimental
6+
```
7+
jb install github.com/crdsonnet/github-actions-libsonnet@main
8+
```
9+
10+
## Usage
11+
12+
```jsonnet
13+
local ga = import 'github.com/crdsonnet/github-actions-libsonnet/main.libsonnet';
14+
15+
local exampleWorkflow =
16+
ga.workflow.withName('example workflow')
17+
+ ga.workflow.on.pull_request.withBranches(['main'])
18+
+ ga.workflow.withJobs({
19+
example:
20+
ga.job.withRunsOn('ubuntu-latest')
21+
+ ga.job.withSteps(
22+
ga.job.step.withName('Checkout')
23+
+ ga.job.step.withUses('actions/checkout@v4')
24+
),
25+
});
26+
27+
std.manifestYamlDoc(exampleWorkflow, indent_array_in_object=true, quote_keys=false)
28+
29+
```
30+
31+
32+
## Subpackages
33+
34+
* [job](job/index.md)
35+
* [workflow](workflow.md)

0 commit comments

Comments
 (0)