Add Gitea Actions image-build workflow #2
76
.gitea/workflows/build.yaml
Normal file
76
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
name: Build and Push
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Image tag'
|
||||
required: true
|
||||
default: 'latest'
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
concurrency:
|
||||
group: build-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
- name: Test (short)
|
||||
run: go test -short ./...
|
||||
|
||||
build:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Compute image tags
|
||||
id: meta
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
TAG="${{ inputs.tag }}"
|
||||
else
|
||||
TAG="${{ github.ref_name }}"
|
||||
fi
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "sha=sha-$(echo '${{ github.sha }}' | cut -c1-12)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Login to Gitea registry
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login -u ${{ github.actor }} --password-stdin gitea.home.hrajfrisbee.cz
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
IMAGE=gitea.home.hrajfrisbee.cz/${{ github.repository }}
|
||||
docker build \
|
||||
--build-arg GIT_COMMIT=$(echo '${{ github.sha }}' | cut -c1-12) \
|
||||
--label org.opencontainers.image.source=https://gitea.home.hrajfrisbee.cz/${{ github.repository }} \
|
||||
--label org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
|
||||
-t "$IMAGE:${{ steps.meta.outputs.tag }}" \
|
||||
-t "$IMAGE:${{ steps.meta.outputs.sha }}" \
|
||||
.
|
||||
docker push "$IMAGE:${{ steps.meta.outputs.tag }}"
|
||||
docker push "$IMAGE:${{ steps.meta.outputs.sha }}"
|
||||
|
||||
# Only real tag pushes move :latest — an ad-hoc dispatch of an old ref must not clobber it.
|
||||
- name: Push latest (tag builds only)
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
IMAGE=gitea.home.hrajfrisbee.cz/${{ github.repository }}
|
||||
docker tag "$IMAGE:${{ steps.meta.outputs.tag }}" "$IMAGE:latest"
|
||||
docker push "$IMAGE:latest"
|
||||
14
CLAUDE.md
14
CLAUDE.md
@@ -199,8 +199,18 @@ Always append a `Co-Authored-By` trailer to indicate AI assistance:
|
||||
|
||||
Co-Authored-By: Claude <noreply@anthropic.com>
|
||||
|
||||
TODO: no `.gitea/workflows/` CI pipeline exists yet — add a CI/CD subsection here once
|
||||
one is set up.
|
||||
### CI/CD
|
||||
|
||||
`.gitea/workflows/build.yaml` builds the manager image and pushes it to the Gitea
|
||||
registry. Triggers: any tag push, or manual `workflow_dispatch` with a `tag` input.
|
||||
A lightweight `check` job (`go vet` / `go build` / `go test -short`) gates the build.
|
||||
|
||||
- Images: `gitea.home.hrajfrisbee.cz/kacerr/egress-proxies-operator:<tag>` plus an
|
||||
immutable `sha-<12-char-commit>` tag on every build; `:latest` moves only on real
|
||||
tag pushes, never on manual dispatch.
|
||||
- Requires the `REGISTRY_TOKEN` repo secret (Gitea PAT with `write:package`),
|
||||
same convention as the other projects on this Gitea instance.
|
||||
- The commit is baked into the binary via the `GIT_COMMIT` build arg (see Dockerfile).
|
||||
|
||||
## Gotchas
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Execution: Distilled Gitea Actions image-build workflow
|
||||
|
||||
Plan: `docs/plans/2026-08-11-1935-gitea-build-workflow.md`
|
||||
|
||||
- [x] Step 1 — Create `.gitea/workflows/build.yaml`
|
||||
- [x] Step 2 — Replace CLAUDE.md CI TODO with a CI/CD subsection
|
||||
- [ ] Step 3 — Push branch + open MR
|
||||
- [ ] Step 4 — CHANGELOG entry (after the first successful run is confirmed)
|
||||
|
||||
## Steps 1–2 — workflow + CLAUDE.md
|
||||
|
||||
The workflow distills the house pattern from 9 sibling projects (survey in the plan)
|
||||
plus improvements none of them combine: an immutable `sha-<12>` tag, a lightweight
|
||||
test gate, `:latest` moving only on real tag pushes, and a `concurrency` group.
|
||||
|
||||
Work happened in a git worktree off `origin/main` so the main checkout (which had
|
||||
unrelated uncommitted changes) stayed untouched:
|
||||
|
||||
```bash
|
||||
git worktree add -b feat/gitea-build-workflow \
|
||||
"$SCRATCH/wt-build" origin/main
|
||||
```
|
||||
|
||||
Deviation from the plan's assumptions: while planning, `feat/proxy-operator` was
|
||||
still unmerged and the plan noted `main` lacked `internal/`/`test/`. By execution
|
||||
time `origin/main` had moved (`076bc66..f7000f7` — the proxy-operator MR merged),
|
||||
so the branch and its CI gate cover the full operator code.
|
||||
|
||||
Verified the workflow parses and the check-gate commands pass on this exact tree
|
||||
(ruby stands in for a YAML linter because the system python3 has no `yaml` module):
|
||||
|
||||
```bash
|
||||
ruby -ryaml -e "YAML.load_file('.gitea/workflows/build.yaml'); puts 'YAML OK'"
|
||||
go vet ./... && go build ./... && go test -short ./... # all packages ok
|
||||
```
|
||||
|
||||
Worth noting: the workflow itself cannot run end-to-end until (a) the MR merges
|
||||
(it only triggers on tags / manual dispatch, not branch pushes) and (b) the
|
||||
`REGISTRY_TOKEN` secret is created in this repo's Gitea settings (PAT with
|
||||
`write:package`). First real verification = manual dispatch with tag
|
||||
`manual-test`, expecting `manual-test` + `sha-…` in Packages and `:latest`
|
||||
untouched.
|
||||
Reference in New Issue
Block a user