git actions

This commit is contained in:
Daniel Noulet 2026-09-19 17:48:04 +02:00
parent 6af2853faa
commit ddd839360a
11 changed files with 310 additions and 164 deletions

80
.github/workflows/build-test-push.yml vendored Normal file
View file

@ -0,0 +1,80 @@
name: Build, test, and publish
on:
push:
branches:
- main
workflow_dispatch:
env:
IMAGE_NAME: batty1039.startdedicated.net:5000/cms-demo
jobs:
build-and-test:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: ui/app/package-lock.json
- name: Install frontend dependencies
run: npm ci
working-directory: ui/app
- name: Build frontend
run: npm run build
working-directory: ui/app
- name: Run Go tests
run: go test ./...
- name: Run Go vet
run: go vet ./...
- name: Build Go backend
run: go build ./cmd/server
publish-image:
name: Build and push Docker image
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Log in to private registry
uses: docker/login-action@v3
with:
registry: batty1039.startdedicated.net:5000
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max