Files
git-cliff-action/entrypoint.sh
Matt Loberg 9b8dd77b6b feat(action): add an output for the changelog content (#4)
* 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 <orhunparmaksiz@gmail.com>
2022-12-01 21:13:59 +01:00

38 lines
821 B
Bash
Executable File

#!/bin/bash -l
set -uxo pipefail
# Avoid file expansion when passing parameters like with '*'
set -o noglob
# Set up working directory
WORKDIR="app"
cp -r . /tmp/gitdir
mv /tmp/gitdir "$WORKDIR"
cd "$WORKDIR" || exit
# Create the output directory
OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"}
mkdir -p "$(dirname $OUTPUT)"
# Separate arguments before passing them to git-cliff command
args=$(echo "$@" | xargs)
# Execute git-cliff
GIT_CLIFF_OUTPUT="$OUTPUT" git-cliff $args
exit_code=$?
# Output to console
cat "$OUTPUT"
# Set the changelog content
echo "content<<EOF" >> $GITHUB_OUTPUT
cat "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Set output file
OUTPUT="$WORKDIR/$OUTPUT"
echo "changelog=$OUTPUT" >> $GITHUB_OUTPUT
# Pass exit code to the next step
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT