ci: run only lint and tests on main, build images on tags and test branches
This commit is contained in:
1 parent
84bc6884b0
commit
3081397fc1
3 files changed
+40
-19
No files matched your search
@@ -1,11 +1,11 @@
|
||||
name: MindSift Multi-Arch Docker Build
|
||||
name: MindSift CI & Docker Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- '**'
|
||||
tags:
|
||||
- 'v*'
|
||||
- '*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
with:
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Run Backend Tests
|
||||
- name: Run Backend Lint & Unit Tests
|
||||
run: |
|
||||
go mod tidy
|
||||
go vet ./...
|
||||
@@ -34,31 +34,37 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Build & Verify Frontend
|
||||
- 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
|
||||
if: github.event_name == 'push'
|
||||
# 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: Prepare Registry Hostname
|
||||
- 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
|
||||
|
||||
- name: Set up QEMU (Multi-Arch)
|
||||
uses: docker/setup-qemu-action@v3
|
||||
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
|
||||
@@ -68,14 +74,13 @@ jobs:
|
||||
with:
|
||||
registry: ${{ steps.prep.outputs.registry }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
password: ${{ secrets.PUSH_TOKEN || secrets.GITEA_TOKEN || gitea.token }}
|
||||
|
||||
- name: Build and Push
|
||||
- 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 }}:latest
|
||||
${{ steps.prep.outputs.image }}:${{ gitea.sha }}
|
||||
${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}
|
||||
Reference in new issue
Block a user