From 6efd46a45e9938dfd8af55cd7b3ac823018acaf8 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Wed, 14 Jan 2026 11:21:27 +0000 Subject: [PATCH 1/2] fix(action): Use environment variables for complex inputs 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. --- action.yml | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/action.yml b/action.yml index 2cbdcfd1..2da354e9 100644 --- a/action.yml +++ b/action.yml @@ -76,10 +76,13 @@ runs: - name: Set git user shell: bash + env: + INPUT_GIT_USER_NAME: ${{ inputs.git_user_name }} + INPUT_GIT_USER_EMAIL: ${{ inputs.git_user_email }} run: | # Use provided values or fall back to triggering actor - GIT_USER_NAME='${{ inputs.git_user_name }}' - GIT_USER_EMAIL='${{ inputs.git_user_email }}' + GIT_USER_NAME="${INPUT_GIT_USER_NAME}" + GIT_USER_EMAIL="${INPUT_GIT_USER_EMAIL}" if [[ -z "$GIT_USER_NAME" ]]; then GIT_USER_NAME="${GITHUB_ACTOR}" @@ -194,21 +197,31 @@ runs: - name: Request publish id: request-publish shell: bash + env: + CHANGELOG: ${{ steps.craft.outputs.changelog }} + TARGETS: ${{ steps.craft-targets.outputs.targets }} + VERSION: ${{ steps.craft.outputs.version }} + BRANCH: ${{ steps.craft.outputs.branch }} + SHA: ${{ steps.craft.outputs.sha }} + PREVIOUS_TAG: ${{ steps.craft.outputs.previous_tag }} + INPUT_PATH: ${{ inputs.path }} + INPUT_MERGE_TARGET: ${{ inputs.merge_target }} + INPUT_PUBLISH_REPO: ${{ inputs.publish_repo }} run: | - if [[ '${{ inputs.path }}' == '.' ]]; then + if [[ "$INPUT_PATH" == "." ]]; then subdirectory='' else - subdirectory='/${{ inputs.path }}' + subdirectory="/$INPUT_PATH" fi - if [[ -n '${{ inputs.merge_target }}' ]]; then - merge_target='${{ inputs.merge_target }}' + if [[ -n "$INPUT_MERGE_TARGET" ]]; then + merge_target="$INPUT_MERGE_TARGET" else merge_target='(default)' fi # Use resolved version from Craft output - RESOLVED_VERSION="${{ steps.craft.outputs.version }}" + RESOLVED_VERSION="$VERSION" if [[ -z "$RESOLVED_VERSION" ]]; then echo "::error::Craft did not output a version. This is unexpected." exit 1 @@ -217,7 +230,7 @@ runs: title="publish: ${GITHUB_REPOSITORY}${subdirectory}@${RESOLVED_VERSION}" # Determine publish repo - PUBLISH_REPO='${{ inputs.publish_repo }}' + PUBLISH_REPO="$INPUT_PUBLISH_REPO" if [[ -z "$PUBLISH_REPO" ]]; then PUBLISH_REPO="${GITHUB_REPOSITORY_OWNER}/publish" fi @@ -234,17 +247,16 @@ runs: fi # 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 # Build changelog section if available - CHANGELOG='${{ steps.craft.outputs.changelog }}' if [[ -n "$CHANGELOG" ]]; then CHANGELOG_SECTION=" --- @@ -264,7 +276,7 @@ runs: Merge target: ${merge_target} Quick links: - - [View changes](https://github.com/${GITHUB_REPOSITORY}/compare/${PREVIOUS_TAG}...${RELEASE_BRANCH}) + - [View changes](https://github.com/${GITHUB_REPOSITORY}/compare/${RELEASE_PREVIOUS_TAG}...${RELEASE_BRANCH}) - [View check runs](https://github.com/${GITHUB_REPOSITORY}/commit/${RELEASE_SHA}/checks/) Assign the **accepted** label to this issue to approve the release. @@ -272,7 +284,7 @@ runs: ### Targets - ${{ steps.craft-targets.outputs.targets }} + ${TARGETS} Checked targets will be skipped (either already published or user-requested skip). Uncheck to retry a target. ${CHANGELOG_SECTION}" From 4e30594d6d910fbd1e91dde41d90918926059471 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Wed, 14 Jan 2026 11:29:48 +0000 Subject: [PATCH 2/2] refactor(action): move bash logic to GHA expressions in env blocks 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. --- action.yml | 63 ++++++++++-------------------------------------------- 1 file changed, 11 insertions(+), 52 deletions(-) diff --git a/action.yml b/action.yml index 2da354e9..981107f6 100644 --- a/action.yml +++ b/action.yml @@ -77,20 +77,9 @@ runs: - name: Set git user shell: bash env: - INPUT_GIT_USER_NAME: ${{ inputs.git_user_name }} - INPUT_GIT_USER_EMAIL: ${{ inputs.git_user_email }} + GIT_USER_NAME: ${{ inputs.git_user_name || github.actor }} + GIT_USER_EMAIL: ${{ inputs.git_user_email || format('{0}+{1}@users.noreply.github.com', github.actor_id, github.actor) }} run: | - # Use provided values or fall back to triggering actor - GIT_USER_NAME="${INPUT_GIT_USER_NAME}" - GIT_USER_EMAIL="${INPUT_GIT_USER_EMAIL}" - - if [[ -z "$GIT_USER_NAME" ]]; then - GIT_USER_NAME="${GITHUB_ACTOR}" - fi - if [[ -z "$GIT_USER_EMAIL" ]]; then - GIT_USER_EMAIL="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" - fi - 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 @@ -200,40 +189,20 @@ runs: env: CHANGELOG: ${{ steps.craft.outputs.changelog }} TARGETS: ${{ steps.craft-targets.outputs.targets }} - VERSION: ${{ steps.craft.outputs.version }} - BRANCH: ${{ steps.craft.outputs.branch }} - SHA: ${{ steps.craft.outputs.sha }} - PREVIOUS_TAG: ${{ steps.craft.outputs.previous_tag }} - INPUT_PATH: ${{ inputs.path }} - INPUT_MERGE_TARGET: ${{ inputs.merge_target }} - INPUT_PUBLISH_REPO: ${{ inputs.publish_repo }} + RESOLVED_VERSION: ${{ steps.craft.outputs.version }} + RELEASE_BRANCH: ${{ steps.craft.outputs.branch }} + RELEASE_SHA: ${{ steps.craft.outputs.sha }} + RELEASE_PREVIOUS_TAG: ${{ steps.craft.outputs.previous_tag || 'HEAD' }} + SUBDIRECTORY: ${{ inputs.path != '.' && format('/{0}', inputs.path) || '' }} + MERGE_TARGET: ${{ inputs.merge_target || '(default)' }} + PUBLISH_REPO: ${{ inputs.publish_repo || format('{0}/publish', github.repository_owner) }} run: | - if [[ "$INPUT_PATH" == "." ]]; then - subdirectory='' - else - subdirectory="/$INPUT_PATH" - fi - - if [[ -n "$INPUT_MERGE_TARGET" ]]; then - merge_target="$INPUT_MERGE_TARGET" - else - merge_target='(default)' - fi - - # Use resolved version from Craft output - RESOLVED_VERSION="$VERSION" if [[ -z "$RESOLVED_VERSION" ]]; then echo "::error::Craft did not output a version. This is unexpected." exit 1 fi - title="publish: ${GITHUB_REPOSITORY}${subdirectory}@${RESOLVED_VERSION}" - - # Determine publish repo - PUBLISH_REPO="$INPUT_PUBLISH_REPO" - if [[ -z "$PUBLISH_REPO" ]]; then - PUBLISH_REPO="${GITHUB_REPOSITORY_OWNER}/publish" - fi + title="publish: ${GITHUB_REPOSITORY}${SUBDIRECTORY}@${RESOLVED_VERSION}" # Check if issue already exists # GitHub only allows search with the "in" operator and this issue search can @@ -246,16 +215,6 @@ runs: exit 0 fi - # Use Craft outputs for git info - RELEASE_BRANCH="$BRANCH" - RELEASE_SHA="$SHA" - RELEASE_PREVIOUS_TAG="$PREVIOUS_TAG" - - # Fall back to HEAD if no previous tag - if [[ -z "$RELEASE_PREVIOUS_TAG" ]]; then - RELEASE_PREVIOUS_TAG="HEAD" - fi - # Build changelog section if available if [[ -n "$CHANGELOG" ]]; then CHANGELOG_SECTION=" @@ -273,7 +232,7 @@ runs: body="Requested by: @${GITHUB_ACTOR} - Merge target: ${merge_target} + Merge target: ${MERGE_TARGET} Quick links: - [View changes](https://github.com/${GITHUB_REPOSITORY}/compare/${RELEASE_PREVIOUS_TAG}...${RELEASE_BRANCH})