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:latest env: GOTOOLCHAIN: local steps: - name: Checkout code uses: actions/checkout@v6 - 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/${{ gitea.repository }}" docker build -t "$IMAGE:${{ gitea.sha }}" -t "$IMAGE:latest" . docker push "$IMAGE:${{ gitea.sha }}" docker push "$IMAGE:latest"