Skip to content

ci: add 'Release PR Changelog' GitHub action #10

ci: add 'Release PR Changelog' GitHub action

ci: add 'Release PR Changelog' GitHub action #10

name: Release changelog
on:
pull_request:
branches:
- master
types: [ opened, synchronize, reopened ]
jobs:
release-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: npm install -g conventional-changelog-cli
- name: Generate Changelog
id: changelog
run: echo "::set-output name=changelog::$(conventional-changelog -s)"
- name: Get PR Number
run: echo "::set-output name=pr_number::${{ github.event.pull_request.number }}"
- name: Update PR comment
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const prNumber = process.env.PR_NUMBER;
const changelog = fs.readFileSync('changelog.txt', 'utf8'); // assuming changelog output is stored in a file
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
octokit.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `Changelog has been updated. You can review it [here](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md).\n\nChangelog:\n${changelog}`
});
env:
PR_NUMBER: ${{ steps.pr_number.outputs.pr_number }}

Check failure on line 42 in .github/workflows/release-changelog.yml

View workflow run for this annotation

GitHub Actions / Release changelog

Invalid workflow file

The workflow is not valid. .github/workflows/release-changelog.yml (Line: 42, Col: 13): A mapping was not expected
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}