Skip to content

Commit

Permalink
feat: add policy output
Browse files Browse the repository at this point in the history
> Policy that was used to set labels on issue. Value is a stringified JSON object.
  • Loading branch information
jamacku committed Apr 18, 2024
1 parent 0dcf1db commit 5c448a2
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 11 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,33 @@ List of labels that were set based on the provided policy. The output is a strin
> element: ${{ fromJSON(steps.<step-id>.outputs.labels)[0] }}
> ```

### policy

The representation of the policy that was used to set labels. The output is a stringified JSON object.

Example output in JSON format where:

* `template` - the name of the template that was used to parse the issue form
* `section` - key-value pairs where the key is the ID of the issue-form section and the value is an array of the applied labels for the given section

```json
{
"template": "bug.yml",
"section": {
"severity": [ "low" ],
"priority": [ "high" ]
}
}
```

> [!TIP]
>
> Use [`fromJSON`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) function to parse the output to get an object of policy.
>
> ```yml
> severity: ${{ fromJSON(steps.<step-id>.outputs.policy).section.severity }}
> ```

## Policy

It's possible to define a labeling policy to further customize the labeling process. The policy can be defined using `.github/advanced-issue-labeler.yml` configuration file. The structure needs to be as follows:
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ inputs:
outputs:
labels:
description: Labels that were set on issue. Value is a stringified array.
policy:
description: Policy that was used to set labels on issue. Value is a stringified JSON object.

runs:
using: node20
Expand Down
10 changes: 9 additions & 1 deletion dist/action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/labeler.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion dist/labeler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/labeler.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/schema/output.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5c448a2

Please sign in to comment.