Skip to content

update-release-notes #8

update-release-notes

update-release-notes #8

name: Update release notes
on:
repository_dispatch:
types: [update-release-notes]
jobs:
update-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: |
mkdir -p ${{ github.workspace }}/content/${{ github.event.client_payload.product }}/release-notes/
- name: Create release notes list
id: release-note-list
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const templatePath = '${{ github.workspace }}/.github/templates/template.md';
const filePath = '${{ github.workspace }}/content/${{ github.event.client_payload.product }}/release-notes/${{ github.event.client_payload.application-name }}-${{ github.event.client_payload.version }}.md';
const templateFile = fs.readFileSync(templatePath, 'utf8');
const releaseNotesArray = ${{ toJSON(github.event.client_payload.release-notes-array) }};
const replacements = new Map([
["Bump", "Library upgrades"],
]);
const searchesFound = new Set();
const releaseNotesIssues = releaseNotesArray.map(item => {
let issue = `- ${item}`;
for (const [search, replacement] of replacements) {
if (item.startsWith(search)) {
if (!searchesFound.has(search)) {
issue = `- ${replacement}`;
searchesFound.add(search);
} else {
issue = null;
}
break;
}
}
return issue;
}).filter(issue => issue !== null).join('\n');
const fileContent = templateFile
.replace('<title>', '${{ github.event.client_payload.application-name }}-${{ github.event.client_payload.version }}')
.replace('<date>', '${{ github.event.client_payload.date }}')
.replace('<issues>', `\n${releaseNotesIssues}`);
fs.writeFileSync(filePath, fileContent, 'utf8');
- name: Create release notes pull request
id: create-pull-request
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # [email protected]
with:
commit-message: "New release notes for ${{ github.event.client_payload.application-name }}"
branch: release-notes-${{ github.event.client_payload.application-name }}
branch-suffix: random
title: "New release notes for ${{ github.event.client_payload.application-name }}"
delete-branch: true