Skip to content

Commit

Permalink
Clean up gem push output handling
Browse files Browse the repository at this point in the history
Review feedback. Let the normal logging through unhindered but log
errors as GH errors. Avoids double logging in some cases.
  • Loading branch information
markpitchless committed Apr 15, 2021
1 parent 727057e commit 72934f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## [Unreleased]
## [1.2.0] - 2021-04-15

- Fix: clean shell log handling for `gem push` call

## [1.2.0] - 2021-04-15

- Change: name to ruby-gem-push-action. Old name still works due to GH redirects.

## [1.1.0] - 2021-04-15
Expand Down
15 changes: 6 additions & 9 deletions gem-push-action
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ elif [[ $INPUT_RELEASE != true ]]; then
exit 0
fi

# tee the output to get it in the logs but capture as we can't tell why gem
# push failed from the exit code, so need to grep the output. Gem existing is
# ok, other errors not. Avoids playing games setting up auth differently for
# gem query.
# Capture as we can't tell why gem push failed from the exit code and it logs
# everything to stdout, so need to grep the output. Gem existing is ok, other
# errors not. Avoids playing games setting up auth differently for gem query.
# Note: the glob is intentially unquoted, we want a glob!
if ! gem push --host "$GEM_HOST" $INPUT_PACKAGE_GLOB | tee push.out; then
if ! gem push --host "$GEM_HOST" $INPUT_PACKAGE_GLOB >push.out; then
gemerr=$?
sed 's/^Error:/::error::/' push.out
if grep -q "has already been pushed" push.out; then
echo Gem Already Pushed
exit 0
exit 0
fi
echo ::error::Gem Push Failed
sed 's/^/::error::/' push.out
exit $gemerr
fi

Expand Down

0 comments on commit 72934f9

Please sign in to comment.