https://github.com/crdsonnet/github-actions-libsonnet
Jsonnet library for generating Github Actions workflows.
https://github.com/crdsonnet/github-actions-libsonnet
Last synced: over 1 year ago
JSON representation
Jsonnet library for generating Github Actions workflows.
- Host: GitHub
- URL: https://github.com/crdsonnet/github-actions-libsonnet
- Owner: crdsonnet
- License: apache-2.0
- Created: 2023-10-03T15:18:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T15:05:17.000Z (over 1 year ago)
- Last Synced: 2025-01-16T01:14:49.370Z (over 1 year ago)
- Language: Jsonnet
- Size: 233 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE
Awesome Lists containing this project
README
# github-actions-libsonnet
Jsonnet library to create GitHub actions workflows.
## Install
```
jb install github.com/crdsonnet/github-actions-libsonnet@main
```
## Usage
```jsonnet
local ga = import 'github.com/crdsonnet/github-actions-libsonnet/main.libsonnet';
local exampleWorkflow =
ga.workflow.withName('example workflow')
+ ga.workflow.on.pull_request.withBranches(['main'])
+ ga.workflow.withJobs({
example:
ga.job.withRunsOn('ubuntu-latest')
+ ga.job.withSteps([
ga.job.step.withName('Checkout')
+ ga.job.step.withUses('actions/checkout@v4'),
]),
});
ga.util.manifestWorkflow(exampleWorkflow)
```
This can be rendered into a Yaml file like so:
```console
jsonnet -S workflow.jsonnet
```
The output will look like this:
```yaml
name: "example workflow"
on:
pull_request:
branches:
- "main"
jobs:
example:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
```
## Subpackages
* [action](action/index.md)
* [job](job/index.md)
* [util](util.md)
* [workflow](workflow.md)