Skip to content

Generate Changelog

Generate Changelog #99

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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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});