refactor: unify CI workflow - use .forgejo/workflows

- Migrate from .gitea to .forgejo (Forgejo standard naming)
- Merge test + release into single CI workflow
- Test runs on all PRs and main pushes
- Build-push only runs on main after test passes
- Remove container overrides that break docker socket
- Follow unified Forgejo CI pattern from CLAUDE.md
This commit is contained in:
2026-09-14 22:34:01 +09:00
parent 1f959d90c2
commit e1c25b1f79
3 changed files with 96 additions and 89 deletions
-43
View File
@@ -1,43 +0,0 @@
name: ci
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: golang
container:
image: golang:1.26
env:
GOPRIVATE: forgejo.riotpiao.com
GOFLAGS: -mod=readonly
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
steps:
- name: install node (required by JS-based actions)
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git
- uses: actions/checkout@v4
- name: configure git auth for private module fetch
run: |
git config --global url."https://oauth2:${REGISTRY_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
- name: gofmt
run: |
fmt_out="$(gofmt -l ./cmd ./internal)"
if [ -n "$fmt_out" ]; then
echo "$fmt_out"
echo "::error::gofmt found unformatted files, run 'gofmt -w ./cmd ./internal'"
exit 1
fi
- name: go vet
run: go vet ./cmd/... ./internal/...
- name: go build
run: go build ./cmd/kmsvc
- name: go test
run: go test ./cmd/... ./internal/... -race
-46
View File
@@ -1,46 +0,0 @@
name: release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: golang
container:
image: golang:1.26
env:
GOPRIVATE: forgejo.riotpiao.com
REGISTRY_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: install node + git (required by JS-based actions)
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git
- uses: actions/checkout@v4
- name: configure git auth for private module fetch
run: |
git config --global url."https://oauth2:${REGISTRY_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
- name: build cross-platform binaries
run: |
mkdir -p dist
VERSION="${GITHUB_REF_NAME}"
for os in linux darwin; do
for arch in amd64 arm64; do
out="dist/kmsvc-${os}-${arch}"
GOOS=$os GOARCH=$arch go build \
-ldflags "-X forgejo.riotpiao.com/rock/kmsvc-cli/internal/cli.version=${VERSION}" \
-o "${out}" ./cmd/kmsvc
done
done
- name: release
uses: actions/forgejo-release@v2
with:
direction: upload
url: ${{ env.GITHUB_SERVER_URL }}
repo: ${{ env.GITHUB_REPOSITORY }}
release-dir: dist
token: ${{ secrets.GITHUB_TOKEN }}