Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write changelog to a file in the repo #13

Closed
amitav13 opened this issue Dec 2, 2023 · 5 comments
Closed

Write changelog to a file in the repo #13

amitav13 opened this issue Dec 2, 2023 · 5 comments

Comments

@amitav13
Copy link

amitav13 commented Dec 2, 2023

Hi,
Might be doing something dumb, but - is there no way to write the changelog to a CHANGELOG.md within the repo itself? Is that not something that's usual?

Thanks for the action!

@orhun
Copy link
Owner

orhun commented Dec 3, 2023

Hello!

You can probably do something like this:

jobs:
  changelog:
    name: Generate changelog
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Generate a changelog
        uses: orhun/git-cliff-action@v2
        with:
          config: cliff.toml
          args: --verbose
        env:
          OUTPUT: CHANGELOG.md

      - name: Commit
        run: |
          git config user.name 'github-actions[bot]'
          git config user.email 'github-actions[bot]@users.noreply.github.com'
          set +e
          git add CHANGELOG.md
          git commit -m "Update changelog"
          git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git upstream

First it creates the changelog as CHANGELOG.md and commits it to the repo as GitHub Actions bot user.

I hope this is helpful 🐻 let me know if it works for you and we can probably mention this in README.md

@amitav13
Copy link
Author

amitav13 commented Dec 6, 2023

Hey no, getting this error:
CleanShot 2023-12-06 at 19 09 10

Was getting the same one when I had the ${GITHUB_REPOSITORY} tag as well.

Here's my action yaml:

name: "Tagged release"

on:
  push:
    tags:
      - "[0-9].[0-9].[0-9]*"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  changelog:
    name: Generate changelog
    runs-on: ubuntu-latest
    outputs:
      release_body: ${{ steps.git-cliff.outputs.content }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Generate a changelog
        uses: orhun/git-cliff-action@v2
        id: git-cliff
        with:
          config: cliff.toml
          args: --latest --strip header
        env:
          OUTPUT: CHANGELOG.md
      - name: Commit changes to changelog
        run: |
          git config user.name 'github-actions[bot]'
          git config user.email 'github-actions[bot]@users.noreply.github.com'
          set +e
          git add CHANGELOG.md
          git commit -m "ci: Update changelog"
          git push https://${{ secrets.GITHUB_TOKEN }}@github.com/Get-Salesmonk/saasmonk-chat.git upstream

@orhun
Copy link
Owner

orhun commented Dec 7, 2023

Wait I made a mistake while sharing the example workflow, upstream should actually match the name of the branch that you want to push to (e.g. main).

Can you try again with the correct branch name?

@realfabecker
Copy link

It worked perfectly for my use case, thank you very much!

@orhun
Copy link
Owner

orhun commented Jan 3, 2024

Thanks for confirming! I added this example to the README.md in 9f1ad1d

@orhun orhun closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants