Skip to content

Commit

Permalink
2023.07.03:
Browse files Browse the repository at this point in the history
* fixed: bash/github: init-*.sh: initialization fixup
  • Loading branch information
andry81 committed Jul 3, 2023
1 parent 1c68130 commit 99bd85a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
27 changes: 14 additions & 13 deletions bash/github/init-basic-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# * CHANGELOG_FILE=repo/owner-of-content/repo-with-content/content-changelog.txt
# * ENABLE_PRINT_CURL_RESPONSE_ON_ERROR=1
# * ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME=1
# * ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE=0 # enabled bu default
# * ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE=1 # enabled by default
# * ERROR_ON_EMPTY_CHANGES_WITHOUT_ERRORS=1
#

Expand Down Expand Up @@ -65,6 +65,19 @@ function init_basic_workflow()
gh_eval_github_env
fi

# global variables init
[[ -z "$CONTINUE_ON_INVALID_INPUT" ]] && gh_set_env_var CONTINUE_ON_INVALID_INPUT 0
[[ -z "$CONTINUE_ON_EMPTY_CHANGES" ]] && gh_set_env_var CONTINUE_ON_EMPTY_CHANGES 0
[[ -z "$CONTINUE_ON_RESIDUAL_CHANGES" ]] && gh_set_env_var CONTINUE_ON_RESIDUAL_CHANGES 0
[[ -z "$ENABLE_GENERATE_CHANGELOG_FILE" ]] && gh_set_env_var ENABLE_GENERATE_CHANGELOG_FILE 0
[[ -z "$ENABLE_PRINT_CURL_RESPONSE_ON_ERROR" ]] && gh_set_env_var ENABLE_PRINT_CURL_RESPONSE_ON_ERROR 0
[[ -z "$ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME" ]] && gh_set_env_var ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME 0
[[ -z "$ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE" ]] && gh_set_env_var ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE 1

if (( ENABLE_GENERATE_CHANGELOG_FILE )); then
[[ -z "$CHANGELOG_FILE" ]] && gh_set_env_var CHANGELOG_FILE 'changelog.txt'
fi

if (( ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE )); then
if [[ -z "${GHWF_CHANGELOG_BUF_KEY_SERIALIZED_ARR_STR:+x}" ]]; then # to save buffer between workflow steps
# associated array keys as buffer names
Expand All @@ -83,18 +96,6 @@ function init_basic_workflow()
fi
fi

[[ -z "$CONTINUE_ON_INVALID_INPUT" ]] && CONTINUE_ON_INVALID_INPUT=0
[[ -z "$CONTINUE_ON_EMPTY_CHANGES" ]] && CONTINUE_ON_EMPTY_CHANGES=0
[[ -z "$CONTINUE_ON_RESIDUAL_CHANGES" ]] && CONTINUE_ON_RESIDUAL_CHANGES=0
[[ -z "$ENABLE_GENERATE_CHANGELOG_FILE" ]] && ENABLE_GENERATE_CHANGELOG_FILE=0
[[ -z "$ENABLE_PRINT_CURL_RESPONSE_ON_ERROR" ]] && ENABLE_PRINT_CURL_RESPONSE_ON_ERROR=0
[[ -z "$ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME" ]] && ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME=0
[[ -z "$ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE" ]] && ENABLE_CHANGELOG_BUF_ARR_AUTO_SERIALIZE=1

if (( ENABLE_GENERATE_CHANGELOG_FILE )); then
[[ -n "$CHANGELOG_FILE" ]] || CHANGELOG_FILE='changelog.txt'
fi

return 0
}

Expand Down
12 changes: 7 additions & 5 deletions bash/github/init-yq-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,19 @@ source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" ||
tkl_include_or_abort "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/traplib.sh"

tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-diff-workflow.sh"
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/utils.sh"


function yq_init()
{
which yq > /dev/null || return $?

# global variables init
[[ -z "$ENABLE_YAML_PRINT_AFTER_EDIT" ]] && gh_set_env_var ENABLE_YAML_PRINT_AFTER_EDIT 0
[[ -z "$ENABLE_YAML_PRINT_AFTER_PATCH" ]] && gh_set_env_var ENABLE_YAML_PRINT_AFTER_PATCH 0
[[ -z "$ENABLE_YAML_DIFF_PRINT_AFTER_EDIT" ]] && gh_set_env_var ENABLE_YAML_DIFF_PRINT_AFTER_EDIT 0
[[ -z "$ENABLE_YAML_DIFF_PRINT_BEFORE_PATCH" ]] && gh_set_env_var ENABLE_YAML_DIFF_PRINT_BEFORE_PATCH 0

local yq_help="$(yq --help)"

# CAUTION:
Expand Down Expand Up @@ -106,11 +113,6 @@ function yq_init()
return 255
fi

[[ -z "$ENABLE_YAML_PRINT_AFTER_EDIT" ]] && ENABLE_YAML_PRINT_AFTER_EDIT=0
[[ -z "$ENABLE_YAML_PRINT_AFTER_PATCH" ]] && ENABLE_YAML_PRINT_AFTER_PATCH=0
[[ -z "$ENABLE_YAML_DIFF_PRINT_AFTER_EDIT" ]] && ENABLE_YAML_DIFF_PRINT_AFTER_EDIT=0
[[ -z "$ENABLE_YAML_DIFF_PRINT_BEFORE_PATCH" ]] && ENABLE_YAML_DIFF_PRINT_BEFORE_PATCH=0

return 0
}

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023.07.03:
* fixed: bash/github: init-*.sh: initialization fixup

2023.07.03:
* fixed: bash/github/print-*.sh: minor fixup
* refactor: bash: replaced `[[ ... ]] && { ... }` expressions by `if [[ ... ]]; then ... fi` statement to reduce places with accidental return code change
Expand Down

0 comments on commit 99bd85a

Please sign in to comment.