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

feat: Add json output #95

Open
stevehipwell opened this issue Oct 12, 2021 · 1 comment
Open

feat: Add json output #95

stevehipwell opened this issue Oct 12, 2021 · 1 comment

Comments

@stevehipwell
Copy link

I'd like to be able drive further actions from the output of the chart releaser action. My suggested implementation would be to return json in the format `[{"chart": "my-chart", "version": "1.0.0", "tag": "my-chart-1.0.0"}].

This output could then be used to drive a matrix. See below for an example of updating the release notes with a CHANGELOG entry (for #44).

name: Release Charts

on:
  push:
    branches:
      - main

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Configure Git
        run: |
          git config user.name "$GITHUB_ACTOR"
          git config user.email "[email protected]"

      - name: Install Helm
        uses: azure/setup-helm@v1
        with:
          version: v3.4.0

      - name: Run chart-releaser
        id: release_step
        uses: helm/[email protected]
        env:
          CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    
    outputs:
       versions: ${{ steps.release_step.outputs.releases }}

  changelog:
    needs: release
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include: ${{ fromJson(needs.release.outputs.versions) }}
    steps:
      - name: Get changelog entry
        id: changelog_reader
        uses: mindsers/changelog-reader-action@v2
        with:
          path: ./charts/${{matrix.chart}}/CHANGELOG.md
          version: "v${{matrix.version}}"

      - name: Update release
        uses: ncipollo/release-action@v1
        with:
          allowUpdates: true
          body: ${{ steps.changelog_reader.outputs.changes }}
          tag: ${{matrix.tag}}
          token: ${{ secrets.GITHUB_TOKEN }}
@pete911
Copy link

pete911 commented Jan 14, 2022

hi @stevehipwell, I've created another project that can be used as github action and it implements the json output you requested. The project is https://github.com/pete911/hcr and there is an example of how to use it as github action.

It logs to stderr, but the result in json is printed in stdout, so you can just run it as hcr 2> /dev/null to get only json output.

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

2 participants