Merge pull request #1115 from mikepenz/feature/1113
Provide categorized PRs as JSON in outputs
This commit is contained in:
@@ -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.deletions` | Count of code deletions in this release (lines). |
|
||||||
| `outputs.changes` | Total count of changes 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.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 🖥️
|
## Full Sample 🖥️
|
||||||
|
|
||||||
@@ -211,6 +211,7 @@ This configuration is a `JSON` in the following format. (The below showcases *ex
|
|||||||
"labels": ["fix"]
|
"labels": ["fix"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"key": "tests",
|
||||||
"title": "## 🧪 Tests",
|
"title": "## 🧪 Tests",
|
||||||
"labels": ["test"]
|
"labels": ["test"]
|
||||||
},
|
},
|
||||||
@@ -419,6 +420,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
|||||||
| **Input** | **Description** |
|
| **Input** | **Description** |
|
||||||
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| categories | An array of `category` specifications, offering a flexible way to group changes into categories. |
|
| 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.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.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. |
|
| 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. |
|
||||||
|
|||||||
+3
@@ -1830,6 +1830,9 @@ function buildChangelog(diffInfo, prs, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(`ℹ️ Ordered all pull requests into ${categories.length} categories`);
|
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
|
// construct final changelog
|
||||||
let changelog = '';
|
let changelog = '';
|
||||||
for (const [category, pullRequests] of categorized) {
|
for (const [category, pullRequests] of categorized) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -19,6 +19,7 @@ export interface Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Category {
|
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
|
title: string // the title of this category
|
||||||
labels?: string[] // labels to associate PRs to 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
|
exclude_labels?: string[] // if an exclude label is detected, the PR will be excluded from this category
|
||||||
|
|||||||
@@ -179,6 +179,12 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
|
|||||||
}
|
}
|
||||||
core.info(`ℹ️ Ordered all pull requests into ${categories.length} categories`)
|
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
|
// construct final changelog
|
||||||
let changelog = ''
|
let changelog = ''
|
||||||
for (const [category, pullRequests] of categorized) {
|
for (const [category, pullRequests] of categorized) {
|
||||||
|
|||||||
Reference in New Issue
Block a user