Generate Changelog #94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | |
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}); |