From 9b8dd77b6b27adfaed37e225e2e89dbd0987dfde Mon Sep 17 00:00:00 2001 From: Matt Loberg Date: Thu, 1 Dec 2022 20:13:59 +0000 Subject: [PATCH] feat(action): add an output for the changelog content (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add an output for the changelog content ::set-output is [deprecated](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) in favor of [environment files](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files). This has better multiline support, so add the contents of the changelog as an output for cases where you are creating a GitHub release. BREAKING CHANGE: self-hosted runners will need to be at 2.297.0 or greater * fix: update multiline output usage https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings * docs(readme): add content as output Co-authored-by: Orhun Parmaksız --- README.md | 1 + action.yml | 2 ++ entrypoint.sh | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bfa70a2..7a2345a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This action generates a changelog based on your Git history using [git-cliff](ht ### Output variables - `changelog`: Output file that contains the generated changelog. +- `content`: Content of the changelog. ### Environment variables diff --git a/action.yml b/action.yml index 37d6bf1..d3a1c12 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,8 @@ inputs: outputs: changelog: description: "output file" + content: + description: "content of the changelog" runs: using: "docker" image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh index a550ff7..29b305c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -23,10 +23,15 @@ exit_code=$? # Output to console cat "$OUTPUT" -OUTPUT="$WORKDIR/$OUTPUT" + +# Set the changelog content +echo "content<> $GITHUB_OUTPUT +cat "$OUTPUT" >> $GITHUB_OUTPUT +echo "EOF" >> $GITHUB_OUTPUT # Set output file -echo "::set-output name=changelog::$OUTPUT" +OUTPUT="$WORKDIR/$OUTPUT" +echo "changelog=$OUTPUT" >> $GITHUB_OUTPUT # Pass exit code to the next step -echo "::set-output name=exit_code::$exit_code" +echo "exit_code=$exit_code" >> $GITHUB_OUTPUT