Skip to content

Commit

Permalink
feat: add labels output
Browse files Browse the repository at this point in the history
> List of labels that were set based on the provided policy. The output is a stringified JSON array.
  • Loading branch information
jamacku committed Apr 17, 2024
1 parent f2f60ec commit 0dcf1db
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ Token used to set labels
* requirements: `required`
* recomended value: `secrets.GITHUB_TOKEN`

## Outputs

### labels

List of labels that were set based on the provided policy. The output is a stringified JSON array.

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

## 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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
required: true
description: GitHub token used to set issue labels

outputs:
labels:
description: Labels that were set on issue. Value is a stringified array.

runs:
using: node20
main: dist/index.js
3 changes: 2 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.

1 change: 1 addition & 0 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.

4 changes: 3 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInput, debug, info } from '@actions/core';
import { getInput, debug, info, setOutput } from '@actions/core';
import { context } from '@actions/github';

import { Config } from './config';
Expand Down Expand Up @@ -41,6 +41,8 @@ async function action(octokit: CustomOctokit) {
}
);

setOutput('labels', JSON.stringify(labels));

debug(`GitHub API response status: [${response.status}]`);
}

Expand Down

0 comments on commit 0dcf1db

Please sign in to comment.