BobAnkh / auto-generate-changelog

A Github Action to generate CHANGELOG automatically according to conventional commits. Feel free to contribute!
Apache License 2.0
81 stars 22 forks source link

[bug] make it so that the action can submit a pull request to update the changelog #78

Closed mmattbtw closed 2 years ago

mmattbtw commented 2 years ago

Is your feature request related to a problem? Please describe

My problem is that my main branch is protected with some required statuses that much be passed. The action tries to push it to the branch directly instead of using a pull request to submit new changes. Which gives this error:

github.GithubException.GithubException: 409 {"message": "Could not update file: 2 of 2 required status checks are expected. Changes must be made through a pull request.", "documentation_url": "docs.github.com/articles/about-protected-branches"}

Description of the new feature/enhancement

I would want the action to either submit a new pull request to update the changelog, or to update the changelog inside of the pull request itself.

Proposed technical implementation details (optional)

A clear and concise description of any solutions you've considered.

Additional context

Add any other context or screenshots about the feature request here.

boring-cyborg[bot] commented 2 years ago

Thanks for opening your first issue here! Be sure to follow the issue template!

gitmagic-app[bot] commented 2 years ago

Everything looks good :thumbsup:

gitmagic-app[bot] commented 2 years ago

Everything looks good :thumbsup:

BobAnkh commented 2 years ago

Hi, I want to know if the option BRANCH and PULL_REQUEST can not be directly used in your case?

image

mmattbtw commented 2 years ago

I just tested this out, and it didn't work https://github.com/mmattDonk/AI-TTS-Donations/blob/9a7175789f9407e63ed1a7ca20b9065bcc1183f1/.github/workflows/changelog.yml#L20-L27

BobAnkh commented 2 years ago

Ok, I think it is my fault that I didn't explain how to use this feature clearly.

This is your originnal workflow:

jobs:
  generate-changelog:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - uses: BobAnkh/auto-generate-changelog@master
      with:
        REPO_NAME: 'mmattDonk/AI-TTS-Donations'
        ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
        PATH: '/CHANGELOG.md'
        COMMIT_MESSAGE: 'docs(CHANGELOG): update release notes'
        TYPE: 'feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements'
        BRANCH: ''
        PULL_REQUEST: 'true'

Here you should specify the pull request from what BRANCH to what PULL_REQUEST branch. For example, set BRANCH to docs/changelog and set PULL_REQUEST to main and you will get a pull request opened from docs/changelog to main.

jobs:
  generate-changelog:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - uses: BobAnkh/auto-generate-changelog@master
      with:
        REPO_NAME: 'mmattDonk/AI-TTS-Donations'
        ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}}
        PATH: 'CHANGELOG.md'
        COMMIT_MESSAGE: 'docs(CHANGELOG): update release notes'
        TYPE: 'feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements'
-        BRANCH: ''
+       BRANCH: 'docs/changelog'
-        PULL_REQUEST: 'true'
+       PULL_REQUEST: 'main'

Use BRANCH to specify where you want to push your changelog first, and use PULL_REQUEST to specify the target branch you want to open a pr. I design this for people who want to push changelog to other branches with or without a pull request.

mmattbtw commented 2 years ago

Still didn't work :/ https://github.com/mmattDonk/AI-TTS-Donations/runs/4656671707?check_suite_focus=true https://github.com/mmattDonk/AI-TTS-Donations/blob/f273790a836b4c1fb4dc241760f669f9dab4e981/.github/workflows/changelog.yml#L20-L27

BobAnkh commented 2 years ago

Ok, thank you. There is a typo leading to the bug. I have fixed it now. Could you please help me test it? Really appreciate your help.

mmattbtw commented 2 years ago

It finished successfully, but didn't make a pr :/ https://github.com/mmattDonk/AI-TTS-Donations/runs/4656755807?check_suite_focus=true

BobAnkh commented 2 years ago

I see. I will try to debug this.

BobAnkh commented 2 years ago

It turns out to be that:

The changelog file will not be created if it has no difference between the new-generated one in action and the current one.

Here is my design trade-off for this. I originally not want to push same things again and again. That is why the pull request not opened.

If you want to see it, just delete the branch docs/changelog and re-run the workflow. Also I will release a new version contains those bug-fixes in master branch.

BobAnkh commented 2 years ago

Hey, if everything works well now, then I will close this issue.

Many thanks for reporting this bug.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue.