Skip to content

fix: action hooks not invoked when config is specified#155

Merged
justinmchase merged 2 commits intomainfrom
copilot/fix-action-not-working-config
Apr 8, 2026
Merged

fix: action hooks not invoked when config is specified#155
justinmchase merged 2 commits intomainfrom
copilot/fix-action-not-working-config

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Post-version hooks were silently skipped whenever the action ran with a config input (including the default .github/version.yml). The CONFIG env var was built with embedded shell quotes via format(' --config \"{0}\"', inputs.config), and because $CONFIG was expanded unquoted in the run script, the path passed to the CLI was ".github/version.yml" — literal quote characters included. Since configPath was non-empty, post.ts never fell back to the default path lookup, and hooks were never invoked.

Changes

  • action.yml: Replace the single-line semver $VAR... expansion with a bash array approach, passing raw values through env vars and adding flags conditionally:
# Before — embedded quotes cause literal `"` chars in the resolved path
CONFIG: "${{ inputs.config && format(' --config \"{0}\"', inputs.config) || '' }}"
# ...
run: semver $COMMAND $SUB_COMMAND ... $CONFIG

# After — raw values, flags added safely in bash
env:
  CONFIG: "${{ inputs.config }}"
run: |
  ARGS=("$COMMAND")
  [[ -n "$SUB_COMMAND" ]] && ARGS+=("$SUB_COMMAND")
  [[ -n "$PRERELEASE" ]] && ARGS+=("--prerelease" "$PRERELEASE")
  [[ -n "$CONFIG" ]] && ARGS+=("--config" "$CONFIG")
  semver "${ARGS[@]}"

This also correctly handles values with spaces (e.g. sort with multiple versions) since sort.ts already splits on whitespace internally.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

The CONFIG env var was constructed with embedded quotes:
  format(' --config \"{0}\"', inputs.config)

When bash expanded $CONFIG unquoted, the path became '".github/version.yml"'
(with literal double-quote characters), which doesn't exist on disk.
Since the config path was non-empty, post.ts didn't fall back to the default
path, so hooks were never invoked.

Fix: pass raw values through env vars and use bash arrays with conditionals
to construct arguments safely, as suggested in the issue.

Agent-Logs-Url: https://github.com/Optum/semver-cli/sessions/5bc2ff24-fbec-44e7-a3de-97e9254885be

Co-authored-by: justinmchase <10974+justinmchase@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug where action does not work when CONFIG is specified fix: action hooks not invoked when config is specified Apr 8, 2026
Copilot AI requested a review from justinmchase April 8, 2026 19:25
@justinmchase justinmchase marked this pull request as ready for review April 8, 2026 19:25
@github-actions github-actions bot added the bug Something isn't working label Apr 8, 2026
@justinmchase justinmchase merged commit 283a555 into main Apr 8, 2026
5 of 6 checks passed
@justinmchase justinmchase deleted the copilot/fix-action-not-working-config branch April 8, 2026 19:37
Copy link
Copy Markdown
Contributor

@joshuaseligman18 joshuaseligman18 left a comment

Choose a reason for hiding this comment

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

Tested and verified it works when inputs.config is not empty. Happy to see the correct BASH syntax for argument expansion for properly handling all inputs and setting the pattern for future inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: action not working when CONFIG is specified

4 participants