Skip to content

fix(action): Use environment variables for complex inputs - #716

Merged
BYK merged 2 commits into
masterfrom
fix/action-syntax-error-env-vars
Jan 14, 2026
Merged

BYK merged 2 commits into
masterfrom
fix/action-syntax-error-env-vars

Conversation

@BYK

@BYK BYK commented Jan 14, 2026

Copy link
Copy Markdown
Member

Description

This PR refactors the 'Set git user' and 'Request publish' steps in action.yml to use environment variables for potentially complex data instead of direct string interpolation in bash scripts.

Problem

Injecting content like ${{ steps.craft.outputs.changelog }} directly into a bash script using single quotes fails if the content contains single quotes or other special characters (e.g., syntax error near unexpected token '(').

Solution

Pass these values as environment variables, which is the recommended and safe way to handle complex string data in GitHub Actions.

Changes

  • Updated 'Set git user' to use INPUT_GIT_USER_NAME and INPUT_GIT_USER_EMAIL env vars.
  • Updated 'Request publish' to use environment variables for CHANGELOG, TARGETS, VERSION, etc.

Refactor 'Set git user' and 'Request publish' steps in action.yml to use environment variables instead of direct string interpolation. This prevents syntax errors caused by unescaped special characters in fields like the changelog.
@github-actions

github-actions Bot commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (action) Emit publish request issue URL as annotation by BYK in #708

Bug Fixes 🐛

Docker

  • Add image template var and strict template validation by BYK in #713
  • Add GITHUB_API_TOKEN and x-access-token fallbacks for ghcr.io by BYK in #710

Other

  • (action) Use environment variables for complex inputs by BYK in #716
  • (aws-lambda) Skip layer publication for pre-release versions by BYK in #714
  • (prepare) Make NEW-VERSION optional and auto-create changelog by BYK in #715
  • Don't mention PRs to avoid linking in changelog previews by BYK in #712

🤖 This preview updates automatically when you update the PR.

Comment thread action.yml Outdated
Comment on lines +80 to +81
INPUT_GIT_USER_NAME: ${{ inputs.git_user_name }}
INPUT_GIT_USER_EMAIL: ${{ inputs.git_user_email }}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not doing this

Suggested change
INPUT_GIT_USER_NAME: ${{ inputs.git_user_name }}
INPUT_GIT_USER_EMAIL: ${{ inputs.git_user_email }}
GIT_USER_NAME: ${{ inputs.git_user_name }}
GIT_USER_EMAIL: ${{ inputs.git_user_email }}

And then getting rid of the assigments on lines 84 and 85?

Comment thread action.yml Outdated
Comment on lines 87 to 92

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we can also fold this logic into the env block, making it safer and tidier? The less bash the better?

Comment thread action.yml
Comment on lines 94 to 96
echo "GIT_COMMITTER_NAME=${GIT_USER_NAME}" >> $GITHUB_ENV
echo "GIT_AUTHOR_NAME=${GIT_USER_NAME}" >> $GITHUB_ENV
echo "EMAIL=${GIT_USER_EMAIL}" >> $GITHUB_ENV

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can lift these up to job level env block and completly get rid of the Set git user step?

Comment thread action.yml Outdated

# Use resolved version from Craft output
RESOLVED_VERSION="${{ steps.craft.outputs.version }}"
RESOLVED_VERSION="$VERSION"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the RESOLVED_VERSION - VERSION indirection? Why not map the value directly to RESOLVED_VERSION in the env block above?

Comment thread action.yml Outdated
Comment on lines 217 to 221
if [[ -n "$INPUT_MERGE_TARGET" ]]; then
merge_target="$INPUT_MERGE_TARGET"
else
merge_target='(default)'
fi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic can also be folded in to the env block above.

Comment thread action.yml Outdated
Comment on lines 249 to 257
# Use Craft outputs for git info
RELEASE_BRANCH="${{ steps.craft.outputs.branch }}"
RELEASE_SHA="${{ steps.craft.outputs.sha }}"
PREVIOUS_TAG="${{ steps.craft.outputs.previous_tag }}"
RELEASE_BRANCH="$BRANCH"
RELEASE_SHA="$SHA"
RELEASE_PREVIOUS_TAG="$PREVIOUS_TAG"

# Fall back to HEAD if no previous tag
if [[ -z "$PREVIOUS_TAG" ]]; then
PREVIOUS_TAG="HEAD"
if [[ -z "$RELEASE_PREVIOUS_TAG" ]]; then
RELEASE_PREVIOUS_TAG="HEAD"
fi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same like others: this entire logic block can be put into the env block.

Address PR review comments by simplifying 'Set git user' and 'Request publish' steps. Move variable calculation and default value logic from bash into GitHub Actions expressions within 'env' blocks.
@BYK
BYK marked this pull request as ready for review January 14, 2026 11:29
@BYK

BYK commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

I have addressed the review comments by refactoring the bash logic into GitHub Actions expressions in the env blocks. This makes the steps tidier and safer.

@philprime philprime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BYK
BYK merged commit 32c2e8e into master Jan 14, 2026
16 checks passed
@BYK
BYK deleted the fix/action-syntax-error-env-vars branch January 14, 2026 11:36

This branch was previously deployed

1 inactive deployment
false — 4e30594d Deployed Jan 14, 2026 by BYK via Build #2343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants