Higher-Kinded Type
Higher-Kinded Type

Reputation: 2054

Capturing (git) command output in github actions

I am trying to capture the output of this git command (or any for that matter).

git diff-tree --no-commit-id --patch-with-raw -r HEAD  # HEAD or some commit SHA

However, unlike an echo, the following command does not log any output in the GitHub actions log. Nor does it streams the output to a variable. On my local, the same command logs the changes made in the last commit.

# result is empty
result=$(git diff-tree --no-commit-id --patch-with-raw -r HEAD)

What am I missing? How do I capture the output of the above git command?

Upvotes: 1

Views: 2020

Answers (2)

LeadingMoominExpert
LeadingMoominExpert

Reputation: 352

Are you using the checkout action to checkout your code? git diff-tree probably doesn't output anything if you're not fetching the history. Try

- uses: actions/checkout@v2
  with:
    fetch-depth: 0

Upvotes: 3

Martin Zeitler
Martin Zeitler

Reputation: 76619

Probably something alike this... in every case with echo:

echo $(git diff-tree --no-commit-id --patch-with-raw -r HEAD)

Upvotes: 1

Related Questions