Skip to content

Generate Changelog

Generate Changelog #85

name: Generate Changelog
on: workflow_dispatch
permissions:
contents: read
jobs:
generate_changelog:
name: 'Generate Changelog'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Configure GIT
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Generate Changelog
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const {run} = require('./.github/workflows/scripts/generate-changelog.cjs');
const {branchName, commitName, content, errors, changelogs} = await run();
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;
const title = commitName;
const head = branchName;
const base = 'main';
const bodyChangelogs = changelogs.map(c => `- ${c}`).join('\n');
const bodyErrors = errors.length !== 0 ? `Got the following errors:\n${errors.map(e => `- ${e}`).join('\n')}` : '';
const body = `Resulting CHANGELOG at:\n${bodyChangelogs}\n\n${bodyErrors}`
await github.rest.pulls.create({owner, repo, title, head, base, body});