Skip to content

Commit

Permalink
Merge pull request #26 from base-org/ci-cd
Browse files Browse the repository at this point in the history
Add CI/CD
  • Loading branch information
danyalprout authored May 30, 2024
2 parents 39cf8e7 + 3abf57b commit ccdfbf9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ccdfbf9

Please sign in to comment.