Skip to content

Commit

Permalink
Merge pull request #1115 from mikepenz/feature/1113
Browse files Browse the repository at this point in the history
Provide categorized PRs as JSON in outputs
  • Loading branch information
mikepenz committed May 25, 2023
2 parents 615fcaf + 61be84a commit 8cdbe23
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ A full set list of possible output values for this action.
| `outputs.deletions` | Count of code deletions in this release (lines). |
| `outputs.changes` | Total count of changes in this release (lines). |
| `outputs.commits` | Count of commits which have been added in this release. |

| `outputs.categorized` | The categorized pull requests used to build the changelog as serialized JSON. |

## Full Sample 🖥️

Expand Down Expand Up @@ -211,6 +211,7 @@ This configuration is a `JSON` in the following format. (The below showcases *ex
"labels": ["fix"]
},
{
"key": "tests",
"title": "## 🧪 Tests",
"labels": ["test"]
},
Expand Down Expand Up @@ -419,6 +420,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
| **Input** | **Description** |
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| categories | An array of `category` specifications, offering a flexible way to group changes into categories. |
| category.key | Optional key used for the `categorized` json output. |
| category.title | The display name of a category in the changelog. |
| category.labels | An array of labels, to match pull request labels against. If any PR label matches any category label, the pull request will show up under this category. (See `exhaustive` to change this) |
| category.exclude_labels | Similar to `labels`, an array of labels to match PRs against, but if a match occurs the PR is excluded from this category. |
Expand Down
3 changes: 3 additions & 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.

1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface Configuration {
}

export interface Category {
key?: string // a key for this category. This is currently only used for the json output
title: string // the title of this category
labels?: string[] // labels to associate PRs to this category
exclude_labels?: string[] // if an exclude label is detected, the PR will be excluded from this category
Expand Down
6 changes: 6 additions & 0 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
}
core.info(`ℹ️ Ordered all pull requests into ${categories.length} categories`)

// serialize and provide the categorized content as json
const transformedCategorized = Array.from(categorized).reduce(
(obj, [key, value]) => Object.assign(obj, {[key.key || key.title]: value}), {}
)
core.setOutput('categorized', JSON.stringify(transformedCategorized))

// construct final changelog
let changelog = ''
for (const [category, pullRequests] of categorized) {
Expand Down

0 comments on commit 8cdbe23

Please sign in to comment.