mirror of
https://github.com/renorris/openfsd
synced 2026-08-13 13:05:41 +08:00
ci: build single binary and publish GHCR image on main/dev
Test builds ./cmd/openfsd only. Docker job builds on PRs and pushes :latest, :dev, and sha tags on push to main and dev.
This commit is contained in:
56
.github/workflows/ci.yml
vendored
56
.github/workflows/ci.yml
vendored
@@ -1,13 +1,16 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [main, dev]
|
||||
pull_request:
|
||||
schedule:
|
||||
# Weekly stress baselines (optional; does not gate PRs on latency).
|
||||
- cron: "0 6 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -20,8 +23,55 @@ jobs:
|
||||
run: go test -race -count=1 ./...
|
||||
- name: Coverage floor ≥80% (exclude cmd/)
|
||||
run: bash scripts/check-coverage.sh 80
|
||||
- name: Build binaries
|
||||
run: go build -o /tmp/openfsd ./cmd/openfsd && go build -o /tmp/openfsd-web ./cmd/openfsd-web
|
||||
- name: Build binary
|
||||
run: go build -o /tmp/openfsd ./cmd/openfsd
|
||||
|
||||
docker:
|
||||
# Build and publish the single openfsd image on every push to main/dev.
|
||||
# PRs only build (no push) to verify the Dockerfile stays green.
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
if: github.event_name == 'push'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
# Always publish branch tip tags; main also updates :latest.
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
||||
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
# While primary work is on dev, keep :latest in sync with dev too.
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
type=sha,prefix=sha-
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
stress:
|
||||
# Optional: scheduled or manual. Never fails on absolute latency thresholds.
|
||||
|
||||
Reference in New Issue
Block a user