From 9b2a204ddc3ff0cb75236fe4e56ee103e32dcbb2 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 4 Mar 2025 20:28:51 +0530 Subject: [PATCH 1/2] ci: added arm64 build and tags build --- .github/workflows/docker.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 42070f9f..b44e63a0 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -5,6 +5,9 @@ on: branches: - main - stable + tags: + - 'v*' + - '*.*.*' workflow_dispatch: permissions: @@ -21,6 +24,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -37,12 +44,17 @@ jobs: uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha - name: Build and push Docker image for main if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest @@ -54,8 +66,20 @@ jobs: uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:stable ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker image for tags + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} From 2452f9413d835508df3e6ea50b57bcbccd0645c8 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 4 Mar 2025 20:37:33 +0530 Subject: [PATCH 2/2] ci: updated to have concise and parallel builds --- .github/workflows/docker.yaml | 58 ++++++++++------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index b44e63a0..05ab7831 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -2,14 +2,14 @@ name: Docker Publish on: push: - branches: - - main - - stable - tags: - - 'v*' - - '*.*.*' + branches: [main, stable] + tags: ['v*', '*.*.*'] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: packages: write contents: read @@ -21,17 +21,14 @@ env: jobs: docker-build-publish: runs-on: ubuntu-latest + # timeout-minutes: 30 steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -45,41 +42,20 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref,event=branch + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=stable,enable=${{ github.ref == 'refs/heads/stable' }} type=ref,event=tag - type=sha + type=sha,format=short + type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stable' }} - - name: Build and push Docker image for main - if: github.ref == 'refs/heads/main' + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 push: true - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push Docker image for stable - if: github.ref == 'refs/heads/stable' - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:stable - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push Docker image for tags - if: startsWith(github.ref, 'refs/tags/') - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Check manifest + run: docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} \ No newline at end of file