Skip to content

Commit 5230710

Browse files
authored
Merge pull request #65 from Henkru/commit-output
feat: provide the commit information as output
2 parents b68767a + ff17660 commit 5230710

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

action.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ inputs:
2424
required: false
2525
default: "."
2626

27+
outputs:
28+
commit-url:
29+
description: The URL of the created commit.
30+
commit-hash:
31+
description: The hash of the created commit.
32+
2733
runs:
2834
using: "docker"
2935
image: "Dockerfile"

entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ ghcommit_args+=("${deletes[@]/#/--delete=}")
7474

7575
[[ -n "${DEBUG:-}" ]] && echo "ghcommit args: '${ghcommit_args[*]}'"
7676

77-
ghcommit "${ghcommit_args[@]}"
77+
output=$(ghcommit "${ghcommit_args[@]}" 2>&1) || {
78+
# Show the output on error. This is needed since the exit immediately flag is set.
79+
echo "$output" 1>&2;
80+
exit 1
81+
}
82+
echo "$output"
83+
84+
commit_url=$(echo "$output" | grep "Success. New commit:" | awk '{print $NF}')
85+
commit_hash=$(echo "$commit_url" | awk -F '/' '{print $NF}')
86+
echo "commit-url=$commit_url" >> "$GITHUB_OUTPUT"
87+
echo "commit-hash=$commit_hash" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)