From dd1daa2caaeef02cb96283b29fa7a9c283d00412 Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Fri, 3 Apr 2026 14:07:53 -0400 Subject: [PATCH] Add GitHub Actions CI/CD with multi-arch Docker builds Replace the legacy Travis CI pipeline with GitHub Actions. The new workflow uses Buildx + QEMU for multi-platform image builds (amd64, arm64, armv7, armv5) and pushes to GHCR with GitVersion semantic versioning. The Dockerfile is updated to use Buildx platform args for native cross-compilation. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ Dockerfile | 18 +++++++----- 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..787f69c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build & Deploy + +on: + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + docker: + name: Build and push docker + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: install GitVersion + uses: gittools/actions/gitversion/setup@v0.11.0 + with: + versionSpec: '5.x' + - name: determine version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.11.0 + - name: set up QEMU + uses: docker/setup-qemu-action@v2 + - name: set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/changemakerstudios/agent + tags: | + type=raw,value=${{ steps.gitversion.outputs.semVer }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} + - name: build and push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v5 + tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index bca32c2..8099dd4 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ -FROM golang:1.25 AS builder +FROM --platform=$BUILDPLATFORM golang:1.25 AS builder + +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT WORKDIR /build ENV CGO_ENABLED=0 -ARG GOOS=linux -ARG GOARCH=amd64 -ARG GOARM -COPY . /build/ -RUN go build -a -installsuffix cgo -o agent . +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} \ + go build -a -installsuffix cgo -o agent . FROM scratch -MAINTAINER Pavol Noha EXPOSE 8080 WORKDIR / COPY --from=builder /build/agent /