From e7561279837c905e6e62091e158adef97fd51c29 Mon Sep 17 00:00:00 2001 From: sindunuragarp Date: Mon, 6 Nov 2023 19:51:43 +0100 Subject: [PATCH] add build and publish step in pipeline --- .github/workflows/go.yaml | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 5ae271fb62c..c90ec46d50e 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -86,3 +86,46 @@ jobs: - name: Run go tests run: | go test -short `go list ./... | grep -v ./test_e2e_arc` + + build: + needs: [fmt, lint, generate, test] + runs-on: ubuntu-latest + env: + REGISTRY_IMAGE: ghcr.io/miroapp/actions-runner-controller + BUILD_PLATFORM: linux/amd64 + BUILD_VERSION: ${{ github.sha }}-${{ github.run_number }} + steps: + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + + - uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:latest + platforms: ${{ env.BUILD_PLATFORM }} + + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + + - uses: docker/build-push-action@v5 + id: build + with: + build-args: | + VERSION=${{ env.BUILD_VERSION }} + TARGETPLATFORM=${{ env.BUILD_PLATFORM }} + TARGETOS=linux + TARGETARCH=amd64 + cache-from: | + type=gha,scope=${{ github.event.repository.default_branch }} + type=gha,scope=${{ github.ref_name }} + cache-to: type=gha,mode=max,scope=${{ github.ref_name }} + platforms: ${{ env.BUILD_PLATFORM }} + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ env.REGISTRY_IMAGE }}:${{ env.BUILD_VERSION }}