diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6652c09 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Tag Docker image + +on: + push: + branches: + - 'master' + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Log into the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push the Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..019f357 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,36 @@ +name: Pull Request + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [ linux/amd64, linux/arm64 ] + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '>=1.21.0' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Go Format + run: make fmt && git diff --exit-code + - name: Go Vet + run: make vet + - name: Go Tidy + run: go mod tidy && git diff --exit-code + - name: Go Mod + run: go mod download + - name: Go Mod Verify + run: go mod verify + - name: Go Test + run: make test + - name: Build Docker + uses: docker/build-push-action@v5 + with: + push: false diff --git a/Makefile b/Makefile index d2a9528..6cbd8bc 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,15 @@ integration: RUN_INTEGRATION_TESTS=true go test -v ./... .PHONY: integration +vet: + go vet ./... +.PHONY: vet + fmt: gofmt -s -w . .PHONY: fmt -check: fmt clean build build-docker lint test integration +check: fmt vet clean build build-docker lint test integration .PHONY: check lint: diff --git a/go.mod b/go.mod index 2cb133e..7e86467 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/go-chi/chi/v5 v5.0.12 github.com/minio/minio-go/v7 v7.0.66 github.com/prometheus/client_golang v1.19.0 + github.com/rs/zerolog v1.32.0 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.1 ) @@ -77,7 +78,6 @@ require ( github.com/rivo/uniseg v0.4.3 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/xid v1.5.0 // indirect - github.com/rs/zerolog v1.32.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect