87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
name: MindSift CI & Docker Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
tags:
|
|
- '*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
name: Lint, Build & Unit Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Run Backend Lint & Unit Tests
|
|
run: |
|
|
go mod tidy
|
|
go vet ./...
|
|
go test -v ./...
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Typecheck & Build Frontend
|
|
run: |
|
|
cd frontend
|
|
npm install --no-audit --no-fund
|
|
npx tsc --noEmit
|
|
npm run build
|
|
|
|
build-docker:
|
|
name: Build & Push Docker Image
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
# Auf 'main' werden nur Tests ausgeführt — gebaut & gepusht wird nur bei Tags oder Test-/RC-Branches
|
|
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Determine Registry & Docker Tag
|
|
id: prep
|
|
run: |
|
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed -E 's#^https?://##' | sed 's#/$##')
|
|
IMAGE_NAME=$(echo "${REGISTRY_HOST}/${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
|
REF_NAME="${GITHUB_REF_NAME}"
|
|
|
|
# Ersetze evtl. Slashes in Branch-Namen (z.B. rc/1.1 -> rc-1.1) für valide Docker-Tags
|
|
DOCKER_TAG=$(echo "${REF_NAME}" | sed 's#/#-#g' | tr '[:upper:]' '[:lower:]')
|
|
|
|
echo "registry=${REGISTRY_HOST}" >> $GITHUB_OUTPUT
|
|
echo "image=${IMAGE_NAME}" >> $GITHUB_OUTPUT
|
|
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
|
|
echo "Building Docker image: ${IMAGE_NAME}:${DOCKER_TAG} (from ref: ${REF_NAME})"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ steps.prep.outputs.registry }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.PUSH_TOKEN || secrets.GITEA_TOKEN || gitea.token }}
|
|
|
|
- name: Build and Push Multi-Arch Image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}
|