ScottBrenner/generate-changelog-action

Changlog from PR

yaacine opened this issue · 8 comments

Hi @ScottBrenner
Is there any way to generate the changelog from the new commit messages within a pull request, please?
Thank you in advance.

Hi - I do believe it is possible to generate changelogs within a pull request using this Action, although I am not sure what the exact workflow would look like. Perhaps something like this (untested)

on:
  pull_request

name: Comment Changelog

jobs:
  build:
    name: Comment Changelog
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Changelog
        uses: scottbrenner/generate-changelog-action@master
        id: Changelog
        env:
          REPO: ${{ github.repository }}
      - name: Create comment
        uses: peter-evans/create-or-update-comment@v1
        with:
          issue-number: 1
          body: |
            ${{ steps.Changelog.outputs.changelog }}

using https://github.com/marketplace/actions/create-or-update-comment

I am not sure how to create pull request comments with GitHub Actions, but if you know how simply setting the comment body to ${{ steps.Changelog.outputs.changelog }} will comment the changelog!

Hi @ScottBrenner ,
thank you for your answer.
what I was trying to do is to include the new commits of a pr within my release body, so I used the following steps

name: Release

on:
  pull_request:
    types: [closed]
    branches: [production]

jobs:
  Release:
    runs-on: ubuntu-latest

    steps:
     - name: Changelog
        uses: scottbrenner/generate-changelog-action@master
        id: Changelog
        env:
          REPO: ${{ github.repository }}

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
        with:
          tag_name: ${{ steps.package-version.outputs.version }}
          release_name: Release ${{ steps.package-version.outputs.version }}
          body: |
            ${{ steps.Changelog.outputs.changelog }}
          draft: false
          prerelease: false

The issue with this is that commit messages within this PR don't figure in the body of the release the only message taken in consideration with this is the message written while merging the PR.

Ah interesting, I'm not sure if that is possible .. suggest checking the options in https://github.com/lob/generate-changelog

@ScottBrenner ,
as mentioned here the generate-changelog project allows to do this,
could you please tell me if this is possible with this action ?

Thank you so much !

Yes, that should be possible with this action.

@ScottBrenner
I tried to use it for a push event and I'm getting the same behavior as for a pull request event, so basically the issue is not related to the event.

I have now an issue which is that when I push 3 commits I get the release body having only the last commit message as shown in the following scenrio

My commits (the 3 top commits)
Screen Shot 2020-09-24 at 8 40 16 AM

The outputs
Screen Shot 2020-09-24 at 8 40 49 AM

Could you please help ?
Thank you.

Believe you'll need to add a "checkout" step with fetch-depth: 0 to your workflow, like:

- name: Checkout code
  uses: actions/checkout@v2
  with:
    fetch-depth: 0

Reference: https://github.com/actions/checkout#checkout-v2

closing stale issue