Skip to content

Commit

Permalink
2023.07.06:
Browse files Browse the repository at this point in the history
* fixed: bash/github/init-basic-workflow.sh: completely removed `GITHUB_ENV` variables conditional load feature, because must always be loaded unconditionally, otherwise variables may be lost on the next shell line of the same GitHub Action step
  • Loading branch information
andry81 committed Jul 6, 2023
1 parent 9678c7b commit 900e249
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 52 deletions.
42 changes: 0 additions & 42 deletions bash/github/enable-github-env-autoeval.sh

This file was deleted.

22 changes: 15 additions & 7 deletions bash/github/init-basic-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,26 @@ fi
source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

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

# does not enable or disable by default, just does include a functionality
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/enable-github-env-autoeval.sh"


function init_basic_workflow()
{
# load GitHub Actions variables at first
if (( GHWF_GITHUB_ENV_AUTOEVAL )); then
gh_eval_github_env
fi
# CAUTION:
# You must always load unconditionally all the `GITHUB_ENV` variables!
#
# The reason is in the method of the bash script execution inside a
# GitHub Action step. While the GitHub Action loads the `GITHUB_ENV`
# variables only in the next step, the variables can be already dropped in
# the current step.
#
# If a bash script inside GitHub Action step does not have a shebang line,
# then each line of it does run as a bash subprocess. This means that the
# all variables would be dropped after a subprocess exit. This function
# reloads the `GITHUB_ENV` on each such subprocess execution.
#
gh_eval_github_env

# global variables init
[[ -z "$CONTINUE_ON_INVALID_INPUT" ]] && gh_set_env_var CONTINUE_ON_INVALID_INPUT 0
Expand Down
13 changes: 13 additions & 0 deletions bash/github/init-github-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ function gh_eval_github_env_file()
done < "$__vars_file"
}

# CAUTION:
# You must always load unconditionally all the `GITHUB_ENV` variables!
#
# The reason is in the method of the bash script execution inside a
# GitHub Action step. While the GitHub Action loads the `GITHUB_ENV`
# variables only in the next step, the variables can be already dropped in
# the current step.
#
# If a bash script inside GitHub Action step does not have a shebang line,
# then each line of it does run as a bash subprocess. This means that the
# all variables would be dropped after a subprocess exit. This function
# reloads the `GITHUB_ENV` on each such subprocess execution.
#
function gh_eval_github_env()
{
[[ -z "$GITHUB_ACTIONS" ]] && return 0
Expand Down
2 changes: 1 addition & 1 deletion bash/github/print-error.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-print-workflow.sh"
function gh_enable_print_error_buffering()
{
if [[ -z "${GHWF_PRINT_ERROR_BUF_STR+x}" ]]; then
gh_set_env_var GHWF_PRINT_ERROR_BUF_STR ''
gh_set_env_var GHWF_PRINT_ERROR_BUF_STR '' # sets to empty to show the variable is initialized
fi
}

Expand Down
2 changes: 1 addition & 1 deletion bash/github/print-notice.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-print-workflow.sh"
function gh_enable_print_notice_buffering()
{
if [[ -z "${GHWF_PRINT_NOTICE_BUF_STR+x}" ]]; then
gh_set_env_var GHWF_PRINT_NOTICE_BUF_STR ''
gh_set_env_var GHWF_PRINT_NOTICE_BUF_STR '' # sets to empty to show the variable is initialized
fi
}

Expand Down
2 changes: 1 addition & 1 deletion bash/github/print-warning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-print-workflow.sh"
function gh_enable_print_warning_buffering()
{
if [[ -z "${GHWF_PRINT_WARNING_BUF_STR+x}" ]]; then
gh_set_env_var GHWF_PRINT_WARNING_BUF_STR ''
gh_set_env_var GHWF_PRINT_WARNING_BUF_STR '' # sets to empty to show the variable is initialized
fi
}

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.06:
* fixed: bash/github/init-basic-workflow.sh: completely removed `GITHUB_ENV` variables conditional load feature, because must always be loaded unconditionally, otherwise variables may be lost on the next shell line of the same GitHub Action step

2023.07.06:
* new: bash/github/enable-print-buffering.sh: added script to explicitly enable print buffering

Expand Down
3 changes: 3 additions & 0 deletions userlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
> :information_source: Legend: :shield: - security; :wrench: - fixed; :new: - new; :pencil: - changed; :twisted_rightwards_arrows: - refactor
## 2023.07.06:
* :wrench: fixed: bash/github/init-basic-workflow.sh: completely removed `GITHUB_ENV` variables conditional load feature, because must always be loaded unconditionally, otherwise variables may be lost on the next shell line of the same GitHub Action step

## 2023.07.06:
* :new: new: bash/github/enable-print-buffering.sh: added script to explicitly enable print buffering

Expand Down

0 comments on commit 900e249

Please sign in to comment.