Reusable CI/CD workflows and scripts for Go projects.
Reusable workflow for Go projects that performs validation and testing.
name: CI
on: [push, pull_request_target]
jobs:
build:
uses: untillpro/ci-action/.github/workflows/ci.yml@main
with:
short_test: 'false' # Optional: run short tests only
go_race: 'false' # Optional: enable race detector
install_tinygo: 'false' # Optional: install TinyGo (needed for voedger)
extra_env: '' # Optional: additional environment variables (multi-line KEY=VALUE)
secrets:
reporeading_token: ${{ secrets.REPOREADING_TOKEN }}What it does:
Job 1: validate-code
- Detects project language (Go or Node.js)
- Checks out code
- Checks hidden folders (no
.folderallowed) - Checks bash script headers (
#!/usr/bin/env bash+set -Eeuo pipefail) - Checks copyright notices
Job 2: run-tests-go (runs only if language is Go)
- Checks out code and sets up Go (auto-detects version from
go.work/go.mod) - Optionally installs TinyGo (if
install_tinygo: 'true') - Applies extra environment variables (if
extra_envprovided) - Validates
go.mod(no localreplacedirectives) - Runs Go tests with private repo access (
github.com/untillpro/*,github.com/heeus/*) - Runs linters (
golangci-lint) - Runs vulnerability check (
govulncheck) unlessshort_test: 'true'
Extends ci.yml with pull request-specific checks. Automatically cancels duplicate workflow runs for the same PR using GitHub's native concurrency control.
name: CI-PR
on: pull_request_target
jobs:
build:
uses: untillpro/ci-action/.github/workflows/ci_pr.yml@main
with:
short_test: 'false' # Optional: same as ci.yml
go_race: 'false' # Optional: same as ci.yml
install_tinygo: 'false' # Optional: same as ci.yml
extra_env: '' # Optional: same as ci.yml
secrets:
reporeading_token: ${{ secrets.REPOREADING_TOKEN }}What it does:
Concurrency Control:
- Automatically cancels previous workflow runs for the same PR when a new commit is pushed
Job 1: pull-request-check
- Checks PR file size limits
Job 2: CI
- Calls
ci.ymlwith all the same inputs and secrets
Cherry pick commits to rc/release branches via issue creation.
Re-create release branch from main.
Create issues programmatically.
Checkout repository and setup Go with auto-detected version:
- uses: untillpro/ci-action/checkout-and-setup-go@main
with:
fetch_depth: 0
# ref: ${{ github.event.pull_request.head.sha }}Inputs:
fetch_depth- Fetch depth for checkout (default: 1)ref- Git ref to checkouttoken- Token for checkoutsubmodules- Submodules optionpath- Path to checkout into (default: ".")go-version- Go version (auto-detected from go.work/go.mod if not specified)
Outputs:
go-version- The Go version being used
Located in scripts/ directory and called directly via curl from workflows.
| Script | Purpose |
|---|---|
detect_language.sh |
Auto-detect project language (Go or Node.js) |
detect-go-version.sh |
Detect Go version from go.work/go.mod |
ci_go.sh |
Run Go tests with private repo access |
ci_node_js.sh |
Run Node.js tests |
| Script | Purpose |
|---|---|
reject_hidden_folders.sh |
Validate repository structure (no hidden folders) |
check_sh_header.sh |
Validate bash script headers |
check_copyright.sh |
Validate copyright notices |
check_gomod.sh |
Validate go.mod has no local replace directives |
| Script | Purpose |
|---|---|
run-linters.sh |
Run golangci-lint |
install-tinygo.sh |
Install TinyGo for a specific Go version |
| Script | Purpose |
|---|---|
checkPR.sh |
Check PR file size limits |
| Script | Purpose |
|---|---|
cp.sh |
Cherry-pick commits to rc/release branches |
rc.sh |
Create release candidate branch |
git-release.sh |
Git release utilities |
createissue.sh |
Create GitHub issues |
close-issue.sh |
Close GitHub issues |
add-issue-commit.sh |
Add comment to issue |
unlinkmilestone.sh |
Unlink milestone from issue |
domergepr.sh |
Merge pull request |
| Script | Purpose |
|---|---|
updateConfig.sh |
Update configuration |
deleteDockerImages.sh |
Delete Docker images |
REPOREADING_TOKEN (required)
- Create a personal access token: GitHub Settings > Tokens
- Needs
reposcope to access private repositories - Add as repository or organization secret
- Used for:
- Checking out code
- Accessing private Go modules (
github.com/untillpro/*,github.com/heeus/*)
For regular CI (push and PR):
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request_target:
jobs:
build:
uses: untillpro/ci-action/.github/workflows/ci.yml@main
secrets:
reporeading_token: ${{ secrets.REPOREADING_TOKEN }}For pull requests:
# .github/workflows/ci-pr.yml
name: CI-PR
on:
pull_request_target:
jobs:
build:
uses: untillpro/ci-action/.github/workflows/ci_pr.yml@main
secrets:
reporeading_token: ${{ secrets.REPOREADING_TOKEN }}For voedger (with TinyGo and extra env):
name: CI
on: [push, pull_request_target]
jobs:
build:
uses: untillpro/ci-action/.github/workflows/ci.yml@main
with:
install_tinygo: 'true'
extra_env: |
VOEDGER_SPECIFIC_VAR=value
ANOTHER_VAR=value2
secrets:
reporeading_token: ${{ secrets.REPOREADING_TOKEN }}The scripts and documentation in this project are released under the MIT License