Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Jan 14, 2026

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
Copy link
Contributor

github-actions bot commented Jan 14, 2026

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.

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
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?

action.yml Outdated
Comment on lines 87 to 92
Copy link
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 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
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?

action.yml Outdated

# Use resolved version from Craft output
RESOLVED_VERSION="${{ steps.craft.outputs.version }}"
RESOLVED_VERSION="$VERSION"
Copy link
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?

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
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.

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
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
Copy link
Member Author

BYK commented Jan 14, 2026

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.

Copy link
Member

@philprime philprime left a comment

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
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.

3 participants