Files
foreman/.gitea/workflows/ci.yaml
T
steve c16e1af752
CI / Tidy (push) Successful in 9m42s
CI / Build & Test (push) Successful in 10m25s
CI / Publish Docker Image (push) Successful in 1m12s
ci: push container image to gitea registry on success
2026-05-23 19:36:43 -04:00

53 lines
1.5 KiB
YAML

name: CI
on:
push: { branches: ["*"] }
pull_request: { branches: ["*"] }
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: "go.mod" }
- run: go mod download
- run: go build ./...
- run: go vet ./...
- run: go test -race -count=1 ./...
tidy:
name: Tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: "go.mod" }
- run: |
go mod tidy
git diff --exit-code go.mod go.sum
publish:
name: Publish Docker Image
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [build, tidy]
steps:
- uses: actions/checkout@v4
- name: Log in to Gitea container registry
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.stevedudenhoeffer.com --username "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build and push Docker image
run: |
BRANCH="${{ github.ref_name }}"
SAFE_BRANCH="${BRANCH//\//-}"
REGISTRY="gitea.stevedudenhoeffer.com/steve/foreman"
docker build -t "${REGISTRY}:${SAFE_BRANCH}" .
if [ "${BRANCH}" = "main" ]; then
docker tag "${REGISTRY}:${SAFE_BRANCH}" "${REGISTRY}:latest"
fi
docker push "${REGISTRY}:${SAFE_BRANCH}"
if [ "${BRANCH}" = "main" ]; then
docker push "${REGISTRY}:latest"
fi