Skip to content

Commit

Permalink
Merge pull request #14 from grafana/13-fix-gh-action-parameter-handling
Browse files Browse the repository at this point in the history
fix gh action parameter handling
  • Loading branch information
szkiba authored Jul 26, 2024
2 parents 0062862 + 7c7f81e commit 841de69
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Data model and tooling for the k6 extension registry**

This repository contains the [JSON schema](docs/registry.schema.json) of the k6 extension registry and the [`k6registry`](#k6registry) command line tool for registry processing.
This repository contains the [JSON schema](docs/registry.schema.json) of the k6 extension registry and the [`k6registry`](#k6registry) command line tool for registry processing. The command line tool can also be used as a [GitHub Action](#github-action).

Check [k6 Extension Registry Concept](docs/registry.md) for information on design considerations.

Expand Down Expand Up @@ -46,7 +46,44 @@ If you have a go development environment, the installation can also be done with
go install github.com/grafana/k6registry/cmd/k6registry@latest
```

## Usage
## GitHub Action

`grafana/k6registry` is a GitHub Action that enables k6 extension registry processing and the generation of customized JSON output for different applications. Processing is based on popular `jq` expressions using an embedded `jq` implementation.

The jq filter expression can be specified in the `filter` parameter.

The extension registry is read from the YAML format file specified in the `in` parameter.

Repository metadata is collected using the repository manager APIs. Currently only the GitHub API is supported.

The output of the processing will be written to the standard output by default. The output can be saved to a file using the `out` parameter.

**Parameters**

name | reqired | default | description
-------|---------|---------|-------------
filter | no | `.` | jq compatible filter
in | yes | | input file name
out | no | stdout | output file name
mute | no | `false` | no output, only validation
loose | no | `false` | skip JSON schema validation
lint | no | `false` | enable built-in linter
compact| no | `false` | compact instead of pretty-printed output
raw | no | `false` | output raw strings, not JSON texts
yaml | no | `false` | output YAML instead of JSON

**Example usage**

```yaml
- name: Generate registry in JSON format
uses: grafana/[email protected]
with:
in: "registry.yaml"
out: "registry.json"
filter: "."
```
## CLI
<!-- #region cli -->
## k6registry
Expand Down
12 changes: 6 additions & 6 deletions cmd/k6registry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ func getArgs() []string {

var args []string

if out := getenv("INPUT_MUTE", "false"); len(out) != 0 {
args = append(args, "--mute", out)
if getenv("INPUT_MUTE", "false") == "true" {
args = append(args, "--mute")
}

if out := getenv("INPUT_LOOSE", "false"); len(out) != 0 {
args = append(args, "--loose", out)
if getenv("INPUT_LOOSE", "false") == "true" {
args = append(args, "--loose")
}

if out := getenv("INPUT_LINT", "false"); len(out) != 0 {
args = append(args, "--lint", out)
if getenv("INPUT_LINT", "false") == "true" {
args = append(args, "--lint")
}

if getenv("INPUT_COMPACT", "false") == "true" {
Expand Down
4 changes: 4 additions & 0 deletions releases/v0.1.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
k6registry `v0.1.4` is here 🎉!

This is an internal maintenance release that fixes docker image reference in GitHub action metadata.

3 changes: 3 additions & 0 deletions releases/v0.1.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
k6registry `v0.1.5` is here 🎉!

This is an internal maintenance release that fixes GitHub action parameter handling.

0 comments on commit 841de69

Please sign in to comment.