Skip to content

Commit

Permalink
feat: ✨ add output
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Augustin <dev@andreas-augustin.org>
  • Loading branch information
AndreasAugustin committed Mar 18, 2024
1 parent ca1a97f commit 98b26e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ jobs:
| output | description |
| ------ | ----------- |
| pr_branch | The name of the branch used for the pull request |
| template_git_hash | The template source repository git hash |

**Remarks** Please consider following edge cases

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ outputs:
pr_branch:
description: "The name of the PR branch"
value: ${{ steps.sync.outputs.pr_branch }}
template_git_hash:
description: "The git hash of the template source repository"
value: ${{ steps.sync.outputs.template_git_hash }}
runs:
using: "composite"
# image: "src/Dockerfile"
Expand Down
5 changes: 4 additions & 1 deletion src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ fi
# set the gh action outputs if run with github action.
# Arguments:
# pr_branch
# template_git_hash
#######################################
function set_github_action_outputs() {
echo "::group::set gh action outputs"

local pr_branch=$1
local template_git_hash=$2

info "set github action outputs"

Expand All @@ -97,6 +99,7 @@ function set_github_action_outputs() {
else
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
echo "pr_branch=${pr_branch}" >> "$GITHUB_OUTPUT"
echo "template_git_hash=${template_git_hash}" >> "$GITHUB_OUTPUT"
fi
echo "::endgroup::"
}
Expand Down Expand Up @@ -475,4 +478,4 @@ commit

push_prepare_pr_create_pr

set_github_action_outputs "${PR_BRANCH}"
set_github_action_outputs "${PR_BRANCH}" "${TEMPLATE_GIT_HASH}"

0 comments on commit 98b26e2

Please sign in to comment.