fix(ci): replace single-job workflow with proper 4-job Gitea Actions pipeline (lint → test → build → build → docker)
Some checks failed
CI / lint (push) Successful in 54s
CI / test (push) Failing after 1m13s
CI / build (push) Has been skipped
CI / docker (push) Has been skipped

This commit is contained in:
2026-08-20 17:36:20 +03:00
parent 70768d420e
commit 904c0c35ce

View File

@@ -1,51 +1,135 @@
name: CI
# Required repo secret: PACKAGES_TOKEN
# Generate at: Gitea → User Settings → Applications → Generate New Token
# Scopes: read:package, write:package
# Save as: Repository → Settings → Actions → Secrets → PACKAGES_TOKEN
# Note: GITHUB_TOKEN is read-only for packages in Gitea (issue #23642).
on: on:
push: push:
branches: branches: ["**"]
- master pull_request:
branches: ["master"]
env:
GO_VERSION: "1.26.4"
jobs: jobs:
build-and-deploy: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Code - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Set up Go - uses: actions/setup-go@v5
uses: actions/setup-go@v5
with: with:
go-version: '1.26.4' go-version: ${{ env.GO_VERSION }}
- name: Go Modules Cache - name: Cache Go modules
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: | path: |
~/.cache/go-build
~/go/pkg/mod ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} ~/.cache/go-build
key: go-lint-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: | restore-keys: |
${{ runner.os }}-go- go-lint-${{ runner.os }}-
- name: Lint & Test - name: Download Go modules
run: go mod download
- name: go vet
run: go vet ./...
- name: gofmt check
run: | run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 fmt=$(gofmt -l .)
export PATH=$(go env GOPATH)/bin:$PATH if [ -n "$fmt" ]; then
golangci-lint run ./... echo "Files needing formatting:"
go test -v -race ./... echo "$fmt"
exit 1
fi
test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-test-${{ runner.os }}-
- name: Download Go modules
run: go mod download
- name: Run tests
run: go test ./... -v -race -cover
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-build-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-build-${{ runner.os }}-
- name: Download Go modules
run: go mod download
- name: Build binary
run: go build -o api ./cmd/api
docker:
runs-on: ubuntu-latest
needs: build
if: github.ref_name == 'master'
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry - name: Login to Gitea Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} registry: gitea.mrixs.me
password: ${{ secrets.DOCKER_PASSWORD }} username: ${{ gitea.repository_owner }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Build and Push Docker Image - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true push: true
tags: | tags: |
${{ secrets.DOCKER_USERNAME }}/trip-planner:latest gitea.mrixs.me/mrixs/trip-planner:latest
${{ secrets.DOCKER_USERNAME }}/trip-planner:${{ github.sha }} gitea.mrixs.me/mrixs/trip-planner:${{ github.sha }}
cache-from: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache
cache-to: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache,mode=max