Merge pull request #1115 from mikepenz/feature/1113

Provide categorized PRs as JSON in outputs
This commit is contained in:
Mike Penz
2023-05-25 21:35:23 +02:00
committed by GitHub
5 changed files with 14 additions and 2 deletions
+3 -1
View File
@@ -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 🖥️
@@ -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"]
},
@@ -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. |
Generated Vendored
+3
View File
@@ -1830,6 +1830,9 @@ function buildChangelog(diffInfo, prs, options) {
}
}
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) {
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -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
+6
View File
@@ -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) {