Skip to content

feat: add push retry and commit SHA outputs (STS-2383) - #3

Merged
whyvez merged 6 commits into
mainfrom
feature/STS-2383/add-push-retry-and-commit-sha-outputs
Nov 19, 2026
Merged

whyvez merged 6 commits into
mainfrom
feature/STS-2383/add-push-retry-and-commit-sha-outputs

Conversation

@whyvez

@whyvez whyvez commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

The action now retries its push when another run updated the target branch first, so concurrent updates no longer get lost. It also passes inputs to the shell safely and outputs the pushed commit SHA and its parent.

What and why

  • Push retry: v0.1.0 pushed once. When two runs targeted the same branch, the slower push was rejected (! [rejected] main -> main (fetch first)) and that update was lost. Each attempt now fetches the latest target_branch, re-applies the YAML edit, commits and pushes, up to max_attempts (new input, default 5) with a short random delay. Re-applying the edit instead of rebasing means no conflict handling is needed.
  • Injection-safe inputs: ${{ inputs.* }} was interpolated straight into the bash script, so a " or $(...) in commit_message or new_value broke the step or ran as code. All inputs now go through env: and the value is set with yq strenv().
  • Outputs: new sha (pushed commit) and base_sha (its parent) outputs, so callers can act on the exact commit, e.g. sts-devops starting Spacelift runs pinned to that SHA.
  • Backward compatible: all existing inputs and defaults, the ci(gitops): prefix, --allow-empty, and the yq/diff/patch blank-line workaround are unchanged. Planned as a minor release (v0.2.0).
  • Test workflow (.github/workflows/test.yaml): creates a scratch branch, runs two updates against it concurrently with a commit_message containing " and $(echo pwned), checks both commits land with the message stored literally, checks sha/base_sha, then deletes the branch.
  • Lint: added .trunk/ (actionlint, shellcheck, shfmt, gitleaks, yamllint, markdownlint, prettier, checkov, trufflehog) and .github/workflows/lint.yaml, which runs Trunk as a job named lint. The repo's Default ruleset already required a lint check, but no workflow produced one, so PRs were blocked from merging.
  • README: usage, inputs/outputs tables, concurrency and blank-line notes.
  • Known limitation, unchanged from v0.1.0: a blank line directly next to an edited key is still removed (diff -B only ignores all-blank hunks). Documented in the README.

Testing

Simulated locally with two concurrent runs against a bare repo: one push was rejected and succeeded on retry, both commits landed, sha/base_sha matched, and the "/$(echo pwned) message and value were stored literally.

Still to check on this PR:

  • test workflow green (both update matrix jobs, verify, cleanup)
  • At least one run logs Push rejected (attempt 1/5) (the race is not guaranteed every run; re-run with gh workflow run test.yaml --ref feature/STS-2383/add-push-retry-and-commit-sha-outputs)
  • trunk check --all

After merge:

  • gh release create v0.2.0 --target main --generate-notes -R masterpointio/github-action-gitops-update
  • sts-devops: switch .github/workflows/gitops-update.yaml back to the action pinned to the v0.2.0 SHA (after SubaruTechShare/sts-devops#1640 merges)

Rollback: re-pin callers to v0.1.0 (805dda2cd0307bc19436cb8be6fc647159eadb58).

Ticket

STS-2383

Links

Paired with Claude Code

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a2085ce-0f87-478d-a655-874b5f2f19d8
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

oycyc
oycyc previously approved these changes Nov 19, 2026
Comment thread .github/workflows/test.yaml Resolved
@whyvez
whyvez marked this pull request as ready for review November 19, 2026 14:49
@whyvez
whyvez merged commit e3059d2 into main Nov 19, 2026
8 checks passed
@whyvez
whyvez deleted the feature/STS-2383/add-push-retry-and-commit-sha-outputs branch November 19, 2026 15:17
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