main 2593286

Reusable GitHub Actions workflows for Go, Frontend, and deployment

README.md

gh-actions

Shared GitHub Actions workflows. Add CI, releases, and deploys to a repo with a few lines of YAML.

Workflows

Workflow What it does
go-ci.yml Lint with golangci-lint v2 + run tests
go-release.yml GoReleaser build on tag push (supports pre-releases)
frontend-ci.yml svelte-check, tsc, and/or ESLint (npm or bun)
gordon-deploy.yml Build and push an OCI image to Gordon
dependabot-auto-merge.yml Auto-merge patch/minor Dependabot PRs
discord-notify.yml Send Discord embed notifications via webhook

Usage

All workflows use workflow_call. Point your repo's workflow at one of these with uses:.

Go CI

name: CI
on:
  push:
    branches: [main]
    paths: ['**.go', 'go.mod', 'go.sum', '.golangci.yml', '.github/workflows/**']
  pull_request:
    paths: ['**.go', 'go.mod', 'go.sum', '.golangci.yml', '.github/workflows/**']

jobs:
  ci:
    uses: bnema/gh-actions/.github/workflows/go-ci.yml@main
    with:
      go-version: stable

To route CI through project Make targets:

    with:
      lint-command: make lint
      test-command: make test

If you need to run something before lint/test (code generation, frontend build), use pre-command:

    with:
      pre-command: make build-frontend

For projects that need a specific container (GTK apps, for example):

    with:
      container: archlinux:latest
      pacman-packages: git go webkitgtk-6.0 gtk4 base-devel

Go Release

name: Release
on:
  push:
    tags: ['v*']

jobs:
  release:
    uses: bnema/gh-actions/.github/workflows/go-release.yml@main
    with:
      go-version: stable
    secrets:
      AUR_KEY: ${{ secrets.AUR_KEY }}

AUR_KEY is optional and is passed only to the GoReleaser step for AUR publishing. Add it as a repository secret in the calling repository, or as an organization secret granted to that repository; omit the secrets block when AUR publishing is not needed.

The v* pattern matches stable tags (v1.0.0) and pre-release tags (v1.0.0-rc.1, v1.0.0-alpha.1). GoReleaser handles the distinction if your .goreleaser.yaml includes:

release:
  prerelease: auto
git:
  tag_sort: smartsemver

prerelease: auto reads the semver suffix and marks the GitHub release accordingly. smartsemver (GoReleaser v2.12+) generates changelogs against the previous stable release, not the last pre-release.

Frontend CI

Works for SvelteKit, plain TypeScript, or both. Each check is toggled independently.

SvelteKit with ESLint:

jobs:
  check:
    uses: bnema/gh-actions/.github/workflows/frontend-ci.yml@main
    with:
      package-manager: bun
      run-svelte-check: true
      run-eslint: true

TypeScript only:

    with:
      run-svelte-check: false
      run-tsc: true
      run-eslint: true

ESLint uses the project's own eslint.config.js. If that config includes eslint-plugin-svelte, Svelte files get linted. No workflow-side config needed.

Gordon Deploy

Build and push an image to Gordon after each update to main:

name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    uses: bnema/gh-actions/.github/workflows/gordon-deploy.yml@main
    with:
      image: my-app
    secrets:
      GORDON_REGISTRY: ${{ secrets.GORDON_REGISTRY }}
      GORDON_USERNAME: ${{ secrets.GORDON_USERNAME }}
      GORDON_TOKEN: ${{ secrets.GORDON_TOKEN }}

The workflow publishes a short-SHA tag and, by default, latest. Gordon deploys routes that match either pushed tag. Concurrent runs for the same repository, image, and ref cancel stale builds so an older run cannot overwrite latest. Set push-latest: false when a route follows only commit-derived tags; use the digest output when an immutable image reference is required.

Store GORDON_REGISTRY, GORDON_USERNAME, and GORDON_TOKEN as repository or organization secrets so deployment details do not appear in the caller workflow. Give the project-specific token push access only to the required image repository.

Dependabot Auto-Merge

name: Dependabot Auto-Merge
on: pull_request

jobs:
  auto-merge:
    uses: bnema/gh-actions/.github/workflows/dependabot-auto-merge.yml@main

Merges patch and minor updates automatically. Major versions require manual review.

Inputs Reference

go-ci.yml

Input Default Description
go-version stable Go version
lint-timeout 5m golangci-lint timeout
lint-version latest golangci-lint version
lint-command Optional project lint command; when set, runs instead of golangci-lint-action
test-flags -race -v ./... Flags for go test
test-command Optional project test command; when set, runs instead of go test
pre-command Run before lint and test
container Container image to run in
apt-packages Space-separated apt packages
pacman-packages Space-separated pacman packages

go-release.yml

Input Default Description
go-version stable Go version
goreleaser-version ~> v2 GoReleaser version constraint
goreleaser-args release --clean GoReleaser CLI arguments
node-version Node.js version (skip if empty)
apt-packages Space-separated apt packages
pre-command Run before GoReleaser

Uses the caller workflow's built-in GITHUB_TOKEN automatically. For GoReleaser AUR publishing, pass the optional AUR_KEY secret from the caller as shown above; it is exposed only to the GoReleaser step.

frontend-ci.yml

Input Default Description
node-version 24 Node.js version
package-manager npm npm or bun
working-directory . Directory with package.json
run-svelte-check true Run svelte-check
run-tsc false Run tsc --noEmit
run-eslint true Run ESLint
eslint-args src Arguments passed to eslint

gordon-deploy.yml

Input Default Description
image repository name Image repository name
tag Git tag or short SHA Image tag override
dockerfile ./Dockerfile Dockerfile path
context . Build context
platforms Comma-separated target platforms
push-latest true Also publish latest
cache-from type=gha BuildKit cache source
cache-to type=gha,mode=max BuildKit cache destination

Outputs: image, tag, and digest.

dependabot-auto-merge.yml

Input Default Description
merge-method squash squash, merge, or rebase

golangci-lint v2 Starter Config

A starting point for new Go projects. Copy and adapt per project.

version: "2"

run:
  timeout: 5m
  tests: true

linters:
  default: none
  enable:
    - govet
    - errcheck
    - staticcheck
    - unused
    - ineffassign
    - revive
    - gocritic
    - gocyclo
    - funlen
    - dupl
    - goconst
    - unconvert
    - unparam
    - misspell
    - whitespace
    - nolintlint
    - gosec
    - modernize
    - fatcontext
    - intrange
    - copyloopvar
    - exptostd
    - errorlint
    - bodyclose
    - mnd
    - lll

  settings:
    gocyclo:
      min-complexity: 20
    lll:
      line-length: 140
    mnd:
      checks: [argument, case, condition, return]
      ignored-numbers: ['0', '1', '2', '3', '10', '100']
    govet:
      enable: [nilness, shadow]
    errorlint:
      asserts: false
    nolintlint:
      allow-unused: false
      require-explanation: true
      require-specific: true
    revive:
      rules:
        - name: indent-error-flow
        - name: unused-parameter
        - name: unused-receiver

  exclusions:
    generated: lax
    rules:
      - path: _test\.go
        linters: [dupl, mnd, lll, funlen, goconst, errcheck, gosec]

formatters:
  enable:
    - gofmt

issues:
  max-same-issues: 50

severity:
  default: error

Notable v2 changes from v1: formatters live in their own formatters: section, default: none|standard|all|fast replaces enable-all, and exclusions: replaces issues.exclude-rules.

New linters worth knowing about:

  • modernize flags patterns that have simpler alternatives in recent Go (range-over-int, slices package, etc.)
  • fatcontext catches context.WithValue calls inside loops
  • intrange suggests for range N syntax from Go 1.22
  • copyloopvar flags unnecessary loop variable copies (Go 1.22 changed loop variable semantics)
  • exptostd finds golang.org/x/exp functions that now exist in the standard library

What stays in each repo

These workflows handle the shared CI/CD plumbing. Project-specific configuration stays local:

  • .golangci.yml for linter rules and exclusions
  • .goreleaser.yaml for build targets, archives, and release notes
  • eslint.config.js for ESLint rules and plugins
  • Specialized workflows like AUR publishing or Flatpak builds

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close