refactor: extract inline bash into testable scripts with CI pipeline#132
Merged
0x46616c6b merged 6 commits intomainfrom Apr 23, 2026
Merged
refactor: extract inline bash into testable scripts with CI pipeline#1320x46616c6b merged 6 commits intomainfrom
0x46616c6b merged 6 commits intomainfrom
Conversation
Extract all inline bash logic from action.yml into separate script files under scripts/, add 64 bats-core tests, shellcheck linting, and a CI workflow. Replace curl-based GitHub Deployment creation with actions/github-script using Octokit for type safety and automatic retry/rate-limiting. Key changes: - Extract tag generation, architecture verification, image retagging, and GitOps update logic into individual scripts - Add shared utility library (logging, retry with backoff, validation) - Deduplicate 4x identical file-update loops into process_file_updates() - Replace manual curl+jq deployment creation with actions/github-script - Improve git push retry: exponential backoff (5 attempts) instead of simple chaining (3 attempts) - Fix shellcheck warnings (SC2206: array=($line) -> read -r) - Add CI pipeline: shellcheck, bats tests, action structure validation All inputs (29), outputs (3), and step IDs remain unchanged. Consumers do not need to modify their workflows. Co-Authored-By: Claude <claude@anthropic.com>
flaxel
reviewed
Apr 23, 2026
Contributor
There was a problem hiding this comment.
Could you test the whole refactored implementation already in another repository? 🤔
Contributor
Author
There was a problem hiding this comment.
The PR includes 64 unit tests that cover all extracted bash logic (tag generation, architecture validation, retagging, GitOps updates, deployment annotations). These validate the refactored scripts behave identically to the original inline bash.
I will test it today and report back.
Contributor
Author
There was a problem hiding this comment.
Working examples:
- https://github.com/Staffbase/flux-deployment-reporter/actions/runs/24823603656/job/72654105572
- https://github.com/Staffbase/flux-deployment-reporter/actions/runs/24824061577/job/72655641932
- https://github.com/Staffbase/backstage-app/actions/runs/24824662882/job/72657449873
- https://github.com/Staffbase/backstage-app/actions/runs/24825080705/job/72658830220
- https://github.com/Staffbase/github-policy-agent/actions/runs/24825196612/job/72659408747
- Merge main to include PR #131 (deactivate stale deployments) - Port deactivate_stale_deployments from bash/curl to Octokit in the actions/github-script step - Add mise.toml with bats-core and shellcheck for local dev setup - Update CI workflow to use jdx/mise-action Co-Authored-By: Claude <claude@anthropic.com>
Replace manual npm/git-clone installation of bats and shellcheck with jdx/mise-action, consistent with the local mise.toml setup. Co-Authored-By: Claude <claude@anthropic.com>
Co-Authored-By: Claude <claude@anthropic.com>
Co-Authored-By: Claude <claude@anthropic.com>
Fixes Node.js 20 deprecation warning. Node.js 20 actions will be forced to Node.js 24 starting June 2nd, 2026. Co-Authored-By: Claude <claude@anthropic.com>
flaxel
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
Extracts all inline bash logic from
action.ymlinto separate, testable script files and adds a comprehensive test suite and CI pipeline. This improves maintainability, testability, and reliability without changing any external behavior.Script extraction:
All inline bash from
action.ymlis moved into individual scripts underscripts/, each with a single responsibility. Theaction.ymlshrinks from 464 to ~290 lines and becomes pure orchestration — referencing scripts via${{ github.action_path }}/scripts/*.shwith inputs passed as environment variables.GitHub Deployments via
actions/github-script:Replaces the manual
curl+jqdeployment creation withactions/github-scriptusing Octokit. This provides automatic retry/rate-limiting, type-safe API access, and proper error handling without manual HTTP status parsing.Deduplication and improvements:
while IFS= readloops → singleprocess_file_updates()functionpush || push || push→retry_with_backoff 5 2with exponential backoffarray=($line)(shellcheck SC2206) →read -r file fieldTest suite (64 bats-core tests):
Covers tag generation (all branch/tag combinations), architecture validation, image retagging (with curl mocks), GitOps functions (update, commit, push, annotations), and the full update orchestrator.
CI pipeline:
New workflow with shellcheck linting, bats test execution, and action structure validation (verifies all referenced scripts exist and are executable).
Backward compatibility: All 29 inputs, 3 outputs, and existing step IDs (
preparation,docker_build,docker_retag,update_image) remain unchanged. Consumers do not need to modify their workflows.Checklist
The changes and the PR were generated by Claude.