Files
DiunDashboard/.gitea/workflows/ci.yml
Jean-Luc Makiola 8af8131c9f
All checks were successful
CI / build-test (push) Successful in 1m2s
CI / docker (push) Successful in 2m33s
- **fix(ci):** replace docker buildx with docker build in CI workflow for compatibility
2026-02-25 20:48:52 +01:00

72 lines
2.3 KiB
YAML

name: CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build-test:
runs-on: docker
container:
image: gitea.jeanlucmakiola.de/makiolaj/docker-node-and-go:064281efa4401d6f440edd18dc467929b89d7f71
env:
GOTOOLCHAIN: local
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Check formatting
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "Unformatted files:"
echo "$unformatted"
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run tests with coverage
run: |
go test -v -coverprofile=coverage.out -coverpkg=./... ./...
go tool cover -func=coverage.out | tee coverage.txt
cov=$(go tool cover -func=coverage.out | grep total: | awk '{print substr($3, 1, length($3)-1)}')
cov=${cov%.*}
if [ "$cov" -lt 80 ]; then
echo "::warning::Test coverage is below 80% ($cov%)"
fi
- name: Build binary
run: go build ./...
docker:
runs-on: dind
needs: build-test
if: gitea.event_name == 'push'
env:
DOCKER_HOST: tcp://dind:2375
steps:
- name: Install dependencies
run: apk add --no-cache git
- name: Checkout
run: |
GITEA_HOST="${{ gitea.server_url }}"
GITEA_HOST="${GITEA_HOST#https://}"
GITEA_HOST="${GITEA_HOST#http://}"
git clone "https://oauth2:${{ secrets.GITEA_TOKEN }}@${GITEA_HOST}/${{ gitea.repository }}.git" .
git checkout ${{ gitea.sha }}
- name: Log in to Gitea registry
run: |
REGISTRY="${{ gitea.server_url }}"
REGISTRY="${REGISTRY#https://}"
REGISTRY="${REGISTRY#http://}"
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
- name: Build and push
run: |
REGISTRY="${{ gitea.server_url }}"
REGISTRY="${REGISTRY#https://}"
REGISTRY="${REGISTRY#http://}"
IMAGE="$REGISTRY/$(echo '${{ gitea.repository }}' | tr '[:upper:]' '[:lower:]')"
docker build -t "$IMAGE:${{ gitea.sha }}" -t "$IMAGE:latest" .
docker push "$IMAGE:${{ gitea.sha }}"
docker push "$IMAGE:latest"