A production-ready GitHub Action template built with robust shell scripting patterns, functional-style utilities, and enterprise-grade observability. This repository is designed to help teams create maintainable, testable, and secure shell-based GitHub Actions with minimal boilerplate.
- A minimal, consistent scaffolding for GitHub Actions implemented in Bash.
- Centralized initialization and shared libraries to eliminate repeated setup code.
- A lightweight testing framework and CI-friendly checks.
- Examples and templates for rapid onboarding and customization.
- Clone the repository:
git clone https://github.com/your-username/bash-action-template.git
cd bash-action-template
- Make scripts executable and run the main script locally:
chmod +x scripts/**/*.sh tests/*.sh
./scripts/services/main.sh
- Run the test suite:
./tests/test_runner.sh
The repository is organized to separate concerns clearly:
scripts/
— all shell scripts, grouped by purpose (libraries, services, validation, maintenance).templates/
— reusable file and workflow templates.tests/
— executable tests and a test runner used by CI.docs/
— supplementary documentation and examples.
Core principles used in the implementation:
- Single responsibility per file.
- Centralized initialization to avoid duplication.
- Pure, testable utility functions where practical.
- Strict input validation and secure defaults.
Primary areas you will likely interact with:
scripts/lib/
— shared libraries such ascore.sh
,utils.sh
, andscript_init.sh
.scripts/services/main.sh
— the action's primary entrypoint; extend or replace this for your own logic.scripts/validation/
— quality checks (PR title validation, output verification, etc.).scripts/maintenance/
— developer conveniences (license headers, snippet updates, template generator).
When writing or adding scripts:
- Source libraries from
../lib/
using$(dirname "${BASH_SOURCE[0]}")/../lib/...
. - Use
init_script
fromscript_init.sh
to standardize logging and teardown. - Keep functions small and side-effect free when possible.
This template includes a test harness in tests/test_runner.sh
. CI workflows run the test suite and linting (ShellCheck, shfmt) on every push.
Local checks:
# Static analysis
find . -name "*.sh" -type f | xargs shellcheck
# Formatting checks
find . -name "*.sh" -type f | xargs shfmt -l -d
# Run tests
./tests/test_runner.sh
- Branch from
main
for any feature or fix. - Keep changes small and focused; add or update tests as appropriate.
- Use the provided templates in
templates/
when creating new scripts or workflows.
Contributions are welcome. Please open issues to discuss larger changes before sending a pull request. See CONTRIBUTING.md
for guidelines and the code of conduct.
This project is distributed under the GNU General Public License v3.0. See the LICENSE
file for details.