95 lines
2.9 KiB
YAML
95 lines
2.9 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: |
|
|
SERVER_URL="${GITHUB_SERVER_URL:-https://git.dsit.me}"
|
|
REGISTRY_HOST=$(echo "${SERVER_URL}" | sed -E 's#^https?://##' | sed 's#/$##')
|
|
if [ -z "${REGISTRY_HOST}" ]; then
|
|
REGISTRY_HOST="git.dsit.me"
|
|
fi
|
|
|
|
REPO_PATH="${GITHUB_REPOSITORY:-sandrodach/mindsift}"
|
|
IMAGE_NAME=$(echo "${REGISTRY_HOST}/${REPO_PATH}" | tr '[:upper:]' '[:lower:]')
|
|
REF_NAME="${GITHUB_REF_NAME:-latest}"
|
|
ACTOR_NAME="${GITHUB_ACTOR:-sandrodach}"
|
|
|
|
# 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 "actor=${ACTOR_NAME}" >> "$GITHUB_OUTPUT"
|
|
echo "Building Docker image: ${IMAGE_NAME}:${DOCKER_TAG} (Registry: ${REGISTRY_HOST}, Actor: ${ACTOR_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: ${{ steps.prep.outputs.actor }}
|
|
password: ${{ secrets.PUSH_TOKEN || secrets.GITEA_TOKEN || github.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 }}
|