name: ci on: push: branches: [ main ] tags: [ 'v*' ] pull_request: jobs: test: runs-on: ubuntu-latest services: mariadb: image: mariadb:11 env: MARIADB_DATABASE: gitea_codex MARIADB_USER: gitea_codex MARIADB_PASSWORD: gitea_codex MARIADB_ROOT_PASSWORD: rootpass ports: - 3306:3306 options: >- --health-cmd "mariadb-admin ping -h 127.0.0.1 -uroot -prootpass" --health-interval 5s --health-timeout 5s --health-retries 20 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.25.x' - name: Check formatting shell: bash run: test -z "$(gofmt -l cmd internal)" - name: Test env: DATABASE_URL: sqlite://./ci.db run: go test -race ./... - name: Vet run: go vet ./... - name: Build run: CGO_ENABLED=0 go build -trimpath -o gitea-codex ./cmd/gitea-codex publish: runs-on: ubuntu-latest needs: test if: gitea.event_name == 'push' env: REGISTRY: gitea.reversed.dev IMAGE_NAME: space/gitea-codex steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - name: Login to Gitea container registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Build and push tags shell: bash env: CI_SHA: ${{ gitea.sha }} CI_REF_NAME: ${{ gitea.ref_name }} run: | set -euo pipefail image="${REGISTRY}/${IMAGE_NAME}" docker buildx build --push -t "${image}:sha-${CI_SHA::12}" -t "${image}:${CI_REF_NAME}" . if [ "${CI_REF_NAME}" = "main" ]; then docker buildx build --push -t "${image}:latest" .; fi