From 24d594ac305d83726cca115d26a92d7ee7b9337e Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 2 Sep 2024 15:53:24 +0100 Subject: [PATCH] PLAT-546 - moe to shared workflows --- .ci/build.sh | 14 +++++++ .github/workflows/build-push-Image.yaml | 54 +++++-------------------- Dockerfile | 6 ++- 3 files changed, 28 insertions(+), 46 deletions(-) create mode 100755 .ci/build.sh diff --git a/.ci/build.sh b/.ci/build.sh new file mode 100755 index 0000000..92d2748 --- /dev/null +++ b/.ci/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -eux -o pipefail + +cd cmd/moroz + +export GOOS="linux" + +for GOARCH in "amd64" "arm64" +do + export GOARCH="${GOARCH}" + mkdir -p ../../build/${GOOS}/${GOARCH} + go build -o ../../build/${GOOS}/${GOARCH}/moroz . +done \ No newline at end of file diff --git a/.github/workflows/build-push-Image.yaml b/.github/workflows/build-push-Image.yaml index 0ebb417..ef8e237 100644 --- a/.github/workflows/build-push-Image.yaml +++ b/.github/workflows/build-push-Image.yaml @@ -1,51 +1,15 @@ -name: build-push-image +name: Build, test and push image + +concurrency: ${{ github.ref }} on: push: branches: - - master - pull_request: - branches: - - master + - main jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout cod - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.23' - - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Build the Go application - run: | - mkdir -p build/linux - cd cmd/moroz - go build -o ../../build/linux/moroz . - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build the Docker image - run: docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest . - - - name: Push the Docker image - run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest + build-test-image: + uses: portswigger-apps/shared-workflows/.github/workflows/build-test-image.yaml@main + secrets: inherit + with: + setup-go: true diff --git a/Dockerfile b/Dockerfile index 594b127..8d38926 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ FROM alpine:3.20 +ARG TARGETPLATFORM + RUN apk --update add \ ca-certificates -COPY ./build/linux/moroz /usr/bin/moroz +RUN mkdir /app + +COPY build/${TARGETPLATFORM}/moroz /app/moroz CMD ["moroz"]