@@ -408,6 +408,53 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
|||||||
| tag_resolver.transformer | Defines a regex transformer used to optionally transform the tag after the filter was applied. Allows to adjust the format to e.g. semver. |
|
| tag_resolver.transformer | Defines a regex transformer used to optionally transform the tag after the filter was applied. Allows to adjust the format to e.g. semver. |
|
||||||
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. Values can be a `regex`. Default: allow all base branches |
|
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. Values can be a `regex`. Default: allow all base branches |
|
||||||
|
|
||||||
|
## Experimental 🧪
|
||||||
|
|
||||||
|
Starting with v3.2.0 the action provides an experimental feature of defining `CUSTOM_PLACEHOLDERS`.
|
||||||
|
Custom placeholders allow to extract values from any existing placeholder and insert them into the target template.
|
||||||
|
|
||||||
|
<details><summary><b>Example</b></summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Custom placeholders can be defined via the `configuration.json` as `custom_placeholders`. See the below example json:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"template": "**Epics**\n${{EPIC[*]}}\n\n${{CHANGELOG}}",
|
||||||
|
"pr_template": "- ${{TITLE}} - ${{URL}} ${{EPIC}}",
|
||||||
|
"custom_placeholders": [
|
||||||
|
{
|
||||||
|
"name": "EPIC",
|
||||||
|
"source": "BODY",
|
||||||
|
"transformer": {
|
||||||
|
"pattern": "[\\S\\s]*?(https:\\/\\/corp\\.atlassian\\.net\\/browse\\/EPIC-.{2,4})[\\S\\s]*",
|
||||||
|
"target": "- $1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This example will look for JIRA tickets in the EPIC project, and extract all of these tickets. The exciting part for that case is, that the ticket is PR bound, but can be used in the global TEMPLATE, but equally also in the PR template. This is unique for CUSTOM PLACEHOLDERS as standard palceholders do not offer this functionality.
|
||||||
|
|
||||||
|
| **Input** | **Description** |
|
||||||
|
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| custom_placeholders | An array of `Placeholder` specifications, offering a flexible API to extract custom placeholders from existing placeholders. |
|
||||||
|
| custom_placeholders.name | The name of the custom placeholder. Will be used within the template. |
|
||||||
|
| custom_placeholders.source | The source PLACEHOLDER, requires to be one of the existing Template or PR Template placeholders. |
|
||||||
|
| custom_placeholders.transformer | The transformer specification used to extract the value from the original source PLACEHOLDER. |
|
||||||
|
|
||||||
|
A placeholder with the name as `CUSTOM_PLACEHOLDER` can be used as `${{CUSTOM_PLACEHOLDER}}` in the target template.
|
||||||
|
By default the same restriction applies as for PR vs template placeholder. E.g. a global placeholder can only be used in the global template (and not in the PR template).
|
||||||
|
|
||||||
|
Custom placeholders offer one new feature though. PR related placeholders can be used in the global template via the following syntax:
|
||||||
|
|
||||||
|
- `CUSTOM_PLACEHOLDER[*]` - Will join all found values and insert them at the given location in the global template
|
||||||
|
- `CUSTOM_PLACEHOLDER[0]` / `CUSTOM_PLACEHOLDER[index]` - Will insert the first found value (item at index) into the global template
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
## Contribute 🧬
|
## Contribute 🧬
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+8
-1
@@ -1719,6 +1719,12 @@ function replacePlaceholders(template, placeholderMap /* placeholderKey and orig
|
|||||||
(0, utils_1.createOrSet)(placeholderPrMap, placeholder.name, extractedValue);
|
(0, utils_1.createOrSet)(placeholderPrMap, placeholder.name, extractedValue);
|
||||||
}
|
}
|
||||||
transformed = transformed.replaceAll(`\${{${placeholder.name}}}`, extractedValue);
|
transformed = transformed.replaceAll(`\${{${placeholder.name}}}`, extractedValue);
|
||||||
|
if (core.isDebug()) {
|
||||||
|
core.debug(` Custom Placeholder successfully matched data - ${extractValues} (${placeholder.name})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (core.isDebug() && extractedValue === value) {
|
||||||
|
core.debug(` Custom Placeholder did result in the full original value returned. Skipping. (${placeholder.name})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8817,6 +8823,7 @@ const Endpoints = {
|
|||||||
getAnalysis: ["GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}"],
|
getAnalysis: ["GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}"],
|
||||||
getSarif: ["GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}"],
|
getSarif: ["GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}"],
|
||||||
listAlertInstances: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances"],
|
listAlertInstances: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances"],
|
||||||
|
listAlertsForEnterprise: ["GET /enterprises/{enterprise}/code-scanning/alerts"],
|
||||||
listAlertsForOrg: ["GET /orgs/{org}/code-scanning/alerts"],
|
listAlertsForOrg: ["GET /orgs/{org}/code-scanning/alerts"],
|
||||||
listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"],
|
listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"],
|
||||||
listAlertsInstances: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances", {}, {
|
listAlertsInstances: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances", {}, {
|
||||||
@@ -9550,7 +9557,7 @@ const Endpoints = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const VERSION = "6.1.2";
|
const VERSION = "6.2.0";
|
||||||
|
|
||||||
function endpointsToMethods(octokit, endpointsMap) {
|
function endpointsToMethods(octokit, endpointsMap) {
|
||||||
const newMethods = {};
|
const newMethods = {};
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+454
-341
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -44,12 +44,12 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^28.1.6",
|
"@types/jest": "^28.1.6",
|
||||||
"@types/node": "^18.6.2",
|
"@types/node": "^18.6.4",
|
||||||
"@typescript-eslint/parser": "^5.31.0",
|
"@typescript-eslint/parser": "^5.32.0",
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@vercel/ncc": "^0.34.0",
|
||||||
"eslint": "^8.20.0",
|
"eslint": "^8.21.0",
|
||||||
"eslint-plugin-github": "^4.3.7",
|
"eslint-plugin-github": "^4.3.7",
|
||||||
"eslint-plugin-jest": "^26.6.0",
|
"eslint-plugin-jest": "^26.7.0",
|
||||||
"jest": "^28.1.3",
|
"jest": "^28.1.3",
|
||||||
"jest-circus": "^28.1.3",
|
"jest-circus": "^28.1.3",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
|
|||||||
@@ -342,6 +342,14 @@ function replacePlaceholders(
|
|||||||
createOrSet(placeholderPrMap, placeholder.name, extractedValue)
|
createOrSet(placeholderPrMap, placeholder.name, extractedValue)
|
||||||
}
|
}
|
||||||
transformed = transformed.replaceAll(`\${{${placeholder.name}}}`, extractedValue)
|
transformed = transformed.replaceAll(`\${{${placeholder.name}}}`, extractedValue)
|
||||||
|
|
||||||
|
if (core.isDebug()) {
|
||||||
|
core.debug(` Custom Placeholder successfully matched data - ${extractValues} (${placeholder.name})`)
|
||||||
|
}
|
||||||
|
} else if (core.isDebug() && extractedValue === value) {
|
||||||
|
core.debug(
|
||||||
|
` Custom Placeholder did result in the full original value returned. Skipping. (${placeholder.name})`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user