From c1de516b3f754bdf221fbb8ae8f08ae1c47fac0f Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 17 Jan 2024 17:07:23 -0700 Subject: [PATCH 1/2] Build and push container image for all main line commits: This will make available container images for all commits inbetween releases. Signed-off-by: Jacob Weinstock --- .github/workflows/ci.yaml | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 59a64d31..a4f53d8c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,9 @@ on: env: CGO_ENABLED: 0 GO_VERSION: '1.21' + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} jobs: validate: @@ -60,3 +63,47 @@ jobs: check_hidden: true skip: "./.git,./go.mod,./go.sum" ignore_words_list: ro + + build-and-push-image: + name: Build and push manager image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to ghcr.io + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + type=raw,value=latest + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5.1.0 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 From fc7462dc0e64786ce734ca8f1d26cc7618a59eba Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 17 Jan 2024 18:17:29 -0700 Subject: [PATCH 2/2] Only build arm when we push to the registry: This will speed up PR builds. Signed-off-by: Jacob Weinstock --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4f53d8c..47b8be25 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,4 +106,4 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 + platforms: ${{ github.event_name != 'pull_request' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}