From 9b57184dffe417a19d3d4e0b35b345792b9fcb73 Mon Sep 17 00:00:00 2001 From: Daniel Sy Date: Tue, 29 Apr 2025 10:40:37 +0200 Subject: [PATCH] fix(#3): --- .forgejo/workflows/pipeline.yml | 57 ++++++++++++++++++++++----------- Dockerfile | 2 ++ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.forgejo/workflows/pipeline.yml b/.forgejo/workflows/pipeline.yml index c3f1408..f801e94 100644 --- a/.forgejo/workflows/pipeline.yml +++ b/.forgejo/workflows/pipeline.yml @@ -31,13 +31,6 @@ jobs: # Optional: Commit-SHA für alle Events type=sha,prefix=sha- - - name: Login to registry - uses: docker/login-action@v3 - with: - registry: ${{ steps.repository.outputs.registry }} - username: ${{ secrets.PACKAGES_USER }} - password: ${{ secrets.PACKAGES_TOKEN }} - - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -47,16 +40,44 @@ jobs: buildkitd-flags: '--allow-insecure-entitlement network.host' driver-opts: network=host - - name: Build and push + - name: Build Docker Image + uses: docker/build-push-action@v6 + id: build + with: + context: . + push: false + allow: network.host + network: host + platforms: linux/amd64 + tags: ${{ steps.docker.outputs.tags }} + outputs: type=docker + no-cache: false + + - name: Run Tests in Docker Image + run: | + docker run --rm \ + -v $(pwd):/app \ + -w /app \ + ${{ steps.docker.outputs.tags | split('\n') | first }} \ + go test ./... -v + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.repository.outputs.registry }} + username: ${{ secrets.PACKAGES_USER }} + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: Push Docker Image uses: docker/build-push-action@v6 with: + context: . push: true allow: network.host network: host platforms: linux/amd64,linux/arm64 tags: ${{ steps.docker.outputs.tags }} - - + no-cache: false # name: CI/CD Pipeline # on: push @@ -100,14 +121,14 @@ jobs: # push: true # tags: ${{ env.GITHUB_SERVER_URL }}/${{ secret.GITHUB_REPOSITORY_OWNER }}/loic:${{ github.sha }} - # - name: Set up Go - # uses: actions/setup-go@v3 - # with: - # go-version: '1.24' - # - name: Build Go Binary - # run: go mod tidy && go build -o loic - # - name: Test Go Binary - # run: go test + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.24' + - name: Build Go Binary + run: go mod tidy && go build -o loic + - name: Test Go Binary + run: go test # - name: Debug Variables # run: | # env diff --git a/Dockerfile b/Dockerfile index 06798d8..47d51c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM golang:1.24 AS builder WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o loic . RUN ls -l /app/loic