From 05550edc06d550f760f03e2872fb380dc787f31f Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 20:44:36 +0100 Subject: [PATCH 01/10] fix: :bug: Signed-off-by: Andy Augustin --- README.md | 9 ++------- src/sync_template.sh | 18 ++++++++++++------ templatesync.yml | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 10c604df..9490044d 100644 --- a/README.md +++ b/README.md @@ -394,15 +394,14 @@ or you set the hooks input parameter within the action definition with a related The following hooks are supported (please check [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for a better understanding of the lifecycles). -* `install` is executed after the container has started and after reading and setting up the environment. * `prepull` is executed before the code is pulled from the source repository * `precommit` is executed before the code is commited * `prepush` is executed before the push is executed, right after the commit * `precleanup` is executed before older PRs targeting the same branch are closed * `prepr` is executed before the PR is done -**Remark** The underlying OS is defined by an Alpine container. -E.q. for the installation phase you need to use commands like `apk add --update --no-cache python3` +**Remark** If you need to install aditional tools just install them in an additional step upfront the action invokation. +If using the docker image the underlying OS is defined by an Alpine container. ### Example for the hooks input parameter @@ -441,10 +440,6 @@ Please not the double quotes within the following `prepull echo` command ```yml hooks: - install: - commands: - - apk add --update --no-cache python3 - - python3 --version prepull: commands: - echo "hi, we are within the prepull phase ${MY_VAR}" diff --git a/src/sync_template.sh b/src/sync_template.sh index 3b2036a5..a13c0ee9 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -45,14 +45,20 @@ fi IS_FORCE_PUSH_PR="${IS_FORCE_PUSH_PR:-"false"}" GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories --squash --strategy=recursive -X theirs}" -cmd_from_yml "install" - TEMPLATE_SYNC_IGNORE_FILE_PATH=".templatesyncignore" TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}') -NEW_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") -NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${NEW_TEMPLATE_GIT_HASH}" -PR_BODY="${PR_BODY:-Merge ${SOURCE_REPO_PATH} ${NEW_TEMPLATE_GIT_HASH}}" -debug "new Git HASH ${NEW_TEMPLATE_GIT_HASH}" +SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") + +TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} +NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" +PR_BODY="${PR_BODY:-Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" +PR_BODY_TMP=${PR_BODY} + +debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" +debug "NEW_BRANCH ${NEW_BRANCH}" +debug "PR_BODY ${PR_BODY}" +info "PR_BODY_TMP ${PR_BODY_TMP}" + # Check if the Ignore File exists inside .github folder or if it doesn't exist at all if [[ -f ".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" || ! -f "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then diff --git a/templatesync.yml b/templatesync.yml index f8eb2ec9..d01a7734 100644 --- a/templatesync.yml +++ b/templatesync.yml @@ -1,10 +1,10 @@ # validate hooks: - install: + prepull: commands: - echo "foo ${MY_VAR}" - - echo 'hi, we are within the prepush phase' + - echo 'hi, we are within the prepull phase' prepush: commands: From 03125290fe072f453d4784b5ecd40549538dc42c Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:00:40 +0100 Subject: [PATCH 02/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sync_template.sh b/src/sync_template.sh index a13c0ee9..d347cbe0 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -59,6 +59,9 @@ debug "NEW_BRANCH ${NEW_BRANCH}" debug "PR_BODY ${PR_BODY}" info "PR_BODY_TMP ${PR_BODY_TMP}" +info "SOURCE_REPO ${SOURCE_REPO}" +export TMP="${PR_BODY}" +info "TMP ${TMP}" # Check if the Ignore File exists inside .github folder or if it doesn't exist at all if [[ -f ".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" || ! -f "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then From 3bbf202e5f4917c13fff9c9cfbfe474f58ccb62c Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:05:45 +0100 Subject: [PATCH 03/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index d347cbe0..123dfcb3 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -51,12 +51,12 @@ SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -PR_BODY="${PR_BODY:-Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" +"${PR_BODY:=Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" PR_BODY_TMP=${PR_BODY} debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" debug "NEW_BRANCH ${NEW_BRANCH}" -debug "PR_BODY ${PR_BODY}" +info "PR_BODY ${PR_BODY}" info "PR_BODY_TMP ${PR_BODY_TMP}" info "SOURCE_REPO ${SOURCE_REPO}" From 51f276205dd6bc2633dcd6719002f79c351bd151 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:08:47 +0100 Subject: [PATCH 04/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index 123dfcb3..d6c9135d 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -51,7 +51,7 @@ SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -"${PR_BODY:=Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" +: "${PR_BODY:=Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" PR_BODY_TMP=${PR_BODY} debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" From 24d62fa9a501ad445fbd762405ccd9a075815dc7 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:21:09 +0100 Subject: [PATCH 05/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index d6c9135d..7aa65f3d 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -49,16 +49,18 @@ TEMPLATE_SYNC_IGNORE_FILE_PATH=".templatesyncignore" TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}') SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") -TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} -NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -: "${PR_BODY:=Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}}" -PR_BODY_TMP=${PR_BODY} +export TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} +export NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" +PR_BODY_TMP="${PR_BODY:-"Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" +PR_TITLE_TMP="${PR_TITLE:-"upstream merge template repository"}" debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" debug "NEW_BRANCH ${NEW_BRANCH}" info "PR_BODY ${PR_BODY}" info "PR_BODY_TMP ${PR_BODY_TMP}" +# shellcheck disable=SC2016 +PR_BODY=${PR_BODY_TMP//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} info "SOURCE_REPO ${SOURCE_REPO}" export TMP="${PR_BODY}" info "TMP ${TMP}" From 71d9de5b3198c09dd5d4be6d265124f5d698c698 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:26:27 +0100 Subject: [PATCH 06/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index 7aa65f3d..332c9712 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -51,7 +51,7 @@ SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") export TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} export NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -PR_BODY_TMP="${PR_BODY:-"Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" +: "${PR_BODY:="Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" PR_TITLE_TMP="${PR_TITLE:-"upstream merge template repository"}" debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" @@ -60,7 +60,8 @@ info "PR_BODY ${PR_BODY}" info "PR_BODY_TMP ${PR_BODY_TMP}" # shellcheck disable=SC2016 -PR_BODY=${PR_BODY_TMP//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} +PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} +PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} info "SOURCE_REPO ${SOURCE_REPO}" export TMP="${PR_BODY}" info "TMP ${TMP}" From 624156f08be2799d216e59084c59cf53f28d5a33 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:29:58 +0100 Subject: [PATCH 07/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index 332c9712..2959afc7 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -51,20 +51,20 @@ SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") export TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} export NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -: "${PR_BODY:="Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" +# : "${PR_BODY:="Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" PR_TITLE_TMP="${PR_TITLE:-"upstream merge template repository"}" debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" debug "NEW_BRANCH ${NEW_BRANCH}" info "PR_BODY ${PR_BODY}" -info "PR_BODY_TMP ${PR_BODY_TMP}" +# info "PR_BODY_TMP ${PR_BODY_TMP}" # shellcheck disable=SC2016 -PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} -PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} -info "SOURCE_REPO ${SOURCE_REPO}" -export TMP="${PR_BODY}" -info "TMP ${TMP}" +# PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} +# PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} +# info "SOURCE_REPO ${SOURCE_REPO}" +# export TMP="${PR_BODY}" +# info "TMP ${TMP}" # Check if the Ignore File exists inside .github folder or if it doesn't exist at all if [[ -f ".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" || ! -f "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then From 90dc31a83734f8de24d2afa391be303de7d9bb8d Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:46:51 +0100 Subject: [PATCH 08/10] fix: :bug: Signed-off-by: Andy Augustin --- README.md | 2 +- src/sync_template.sh | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9490044d..2e541df1 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ jobs: | source_repo_ssh_private_key | `[optional]` private ssh key for the source repository. [see](#private-template-repository) | `false` | | | pr_branch_name_prefix | `[optional]` the prefix of branches created by this action | `false` | `chore/template_sync` | | pr_title | `[optional]` the title of PRs opened by this action. Must be already created. | `false` | `upstream merge template repository` | -| pr_body | `[optional]` the body of PRs opened by this action. | `false` | `Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}` | +| pr_body | `[optional]` the body of PRs opened by this action. | `false` | `Merge ${SOURCE_REPO} ${TEMPLATE_GIT_HASH}` | | pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels]. | `false` | `sync_template` | | pr_reviewers | `[optional]` comma separated list of pull request reviewers. | `false` | | | pr_commit_msg | `[optional]` commit message in the created pull request | `false` | `chore(template): merge template changes :up:` | diff --git a/src/sync_template.sh b/src/sync_template.sh index 2959afc7..4f150615 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -50,21 +50,29 @@ TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1} SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}") export TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH} -export NEW_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" -# : "${PR_BODY:="Merge ${SOURCE_REPO_PATH} ${TEMPLATE_GIT_HASH}"}" -PR_TITLE_TMP="${PR_TITLE:-"upstream merge template repository"}" +export PR_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" +: "${PR_BODY:="Merge ${SOURCE_REPO} ${TEMPLATE_GIT_HASH}"}" +: "${PR_TITLE:-"upstream merge template repository"}" -debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" -debug "NEW_BRANCH ${NEW_BRANCH}" -info "PR_BODY ${PR_BODY}" -# info "PR_BODY_TMP ${PR_BODY_TMP}" +# for some reasons the substitution is not working as expected +# so we substitute manually +# shellcheck disable=SC2016 +PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} +# shellcheck disable=SC2016 +PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} +# shellcheck disable=SC2016 +PR_BODY=${PR_BODY//'${PR_BRANCH}'/"${PR_BRANCH}"} # shellcheck disable=SC2016 -# PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} -# PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} -# info "SOURCE_REPO ${SOURCE_REPO}" -# export TMP="${PR_BODY}" -# info "TMP ${TMP}" +PR_TITLE=${PR_TITLE//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} +# shellcheck disable=SC2016 +PR_TITLE=${PR_TITLE//'${SOURCE_REPO}'/"${SOURCE_REPO}"} +# shellcheck disable=SC2016 +PR_TITLE=${PR_TITLE//'${PR_BRANCH}'/"${PR_BRANCH}"} + +debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" +debug "PR_BRANCH ${PR_BRANCH}" +debug "PR_BODY ${PR_BODY}" # Check if the Ignore File exists inside .github folder or if it doesn't exist at all if [[ -f ".github/${TEMPLATE_SYNC_IGNORE_FILE_PATH}" || ! -f "${TEMPLATE_SYNC_IGNORE_FILE_PATH}" ]]; then @@ -85,6 +93,7 @@ function set_github_action_outputs() { echo "::group::set gh action outputs" local pr_branch=$1 + info "set github action outputs" if [[ -z "${GITHUB_RUN_ID}" ]]; then @@ -371,7 +380,7 @@ function prechecks() { warn "skipping prechecks because we force push and pr" return 0 fi - check_branch_remote_existing "${NEW_BRANCH}" + check_branch_remote_existing "${PR_BRANCH}" check_if_commit_already_in_hist_graceful_exit "${TEMPLATE_REMOTE_GIT_HASH}" @@ -385,8 +394,8 @@ function checkout_branch_and_pull() { echo "::group::checkout branch and pull" - debug "create new branch from default branch with name ${NEW_BRANCH}" - git checkout -b "${NEW_BRANCH}" + debug "create new branch from default branch with name ${PR_BRANCH}" + git checkout -b "${PR_BRANCH}" debug "pull changes from template" pull_source_changes "${SOURCE_REPO}" "${GIT_REMOTE_PULL_PARAMS}" @@ -449,7 +458,7 @@ function push_prepare_pr_create_pr() { echo "::group::push changes and create PR" cmd_from_yml "prepush" - push "${NEW_BRANCH}" "${IS_FORCE_PUSH_PR}" + push "${PR_BRANCH}" "${IS_FORCE_PUSH_PR}" cmd_from_yml "prepr" if [ "$IS_FORCE_PUSH_PR" == true ] ; then create_or_edit_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}" @@ -470,4 +479,4 @@ commit push_prepare_pr_create_pr -set_github_action_outputs "${NEW_BRANCH}" +set_github_action_outputs "${PR_BRANCH}" From ca1a97fced8b1edd71d3316b06b77d8783339ec9 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 21:50:27 +0100 Subject: [PATCH 09/10] fix: :bug: Signed-off-by: Andy Augustin --- src/sync_template.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sync_template.sh b/src/sync_template.sh index 4f150615..51ae58bc 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -60,15 +60,11 @@ export PR_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}" PR_BODY=${PR_BODY//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} # shellcheck disable=SC2016 PR_BODY=${PR_BODY//'${SOURCE_REPO}'/"${SOURCE_REPO}"} -# shellcheck disable=SC2016 -PR_BODY=${PR_BODY//'${PR_BRANCH}'/"${PR_BRANCH}"} # shellcheck disable=SC2016 PR_TITLE=${PR_TITLE//'${TEMPLATE_GIT_HASH}'/"${TEMPLATE_GIT_HASH}"} # shellcheck disable=SC2016 PR_TITLE=${PR_TITLE//'${SOURCE_REPO}'/"${SOURCE_REPO}"} -# shellcheck disable=SC2016 -PR_TITLE=${PR_TITLE//'${PR_BRANCH}'/"${PR_BRANCH}"} debug "TEMPLATE_GIT_HASH ${TEMPLATE_GIT_HASH}" debug "PR_BRANCH ${PR_BRANCH}" From 98b26e2a6ac3dd5f3c9b21798bf4783fa0e00e5d Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Mon, 18 Mar 2024 22:22:10 +0100 Subject: [PATCH 10/10] feat: :sparkles: add output Signed-off-by: Andy Augustin --- README.md | 1 + action.yml | 3 +++ src/sync_template.sh | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e541df1..595f5ad7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index b781053b..732db6ae 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/src/sync_template.sh b/src/sync_template.sh index 51ae58bc..df0dfda3 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -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" @@ -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::" } @@ -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}"