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

Added a path to output a list of releases formatted as JSON #18

Merged
merged 4 commits into from
Oct 28, 2021

Conversation

na-ga
Copy link
Contributor

@na-ga na-ga commented Oct 28, 2021

The outputs.releases contain a lot of information, and there are times when we want to remove unnecessary information. In my case, I used the jq command to convert them as follows.

echo '${{ steps.releases.outputs.releases }}' | jq -c '. [] | [{ tag: .tag, name: .name, commits: [ .commits[].hash ]}]'

The outputs.releases may contain meta tags because they contain commit messages by committer. For example, if it contains single quotation marks, the conversion process described above will not work properly. As a workaround, we have added an option to write releases to a specified path. Using this option, we can convert as follows.

      - id: release
        name: Execute gh-release
        uses: na-ga/actions-gh-release@add-write-output-releases-json
        with:
          release_file: 'RELEASE'
          token: ${{ secrets.GITHUB_TOKEN }}
          output_releases_file_path: "./releases.json"
      - id: transform
        name: Set release summaries as output
        run: |
          RELEASE_SUMMARIES=$(cat ./releases.json | jq -c '. [] | [{ tag: .tag, name: .name, commits: [ .commits[].hash ]}]')
          echo "release_summaries: ${RELEASE_SUMMARIES}"
          echo "::set-output name=release_summaries::${RELEASE_SUMMARIES}"

@na-ga na-ga force-pushed the add-write-output-releases-json branch from be2ea14 to 9d51c59 Compare October 28, 2021 04:48
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
na-ga and others added 3 commits October 28, 2021 19:54
Co-authored-by: Le Van Nghia <[email protected]>
Co-authored-by: Le Van Nghia <[email protected]>
Co-authored-by: Le Van Nghia <[email protected]>
@na-ga
Copy link
Contributor Author

na-ga commented Oct 28, 2021

Thanks review!

@nghialv
Copy link
Member

nghialv commented Oct 28, 2021

Thank you.

@nghialv nghialv merged commit ea8674c into pipe-cd:main Oct 28, 2021
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

Successfully merging this pull request may close these issues.

2 participants