From 2e325fe01833b06afbbc20e1476a82e7f6b94dff Mon Sep 17 00:00:00 2001 From: sherl Date: Sun, 7 Dec 2025 20:18:24 +0100 Subject: [PATCH] feat: refactor docker workflow; build both amd64 and arm64 docker images --- .gitea/workflows/docker.yaml | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml index 6743b71..7e2b669 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/docker.yaml @@ -1,4 +1,5 @@ -# Credit: https://www.vanmeeuwen.dev/blog/automating-docker-builds-with-gitea-actions +# Credits: https://www.vanmeeuwen.dev/blog/automating-docker-builds-with-gitea-actions +# https://gitea.com/gitea/runner-images/src/branch/main/.gitea/workflows/release.yaml name: Build and push Docker image run-name: Building image on ${{ gitea.actor }}'s commit @@ -15,6 +16,12 @@ jobs: - name: Checkout repository 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: Login to registry uses: docker/login-action@v2 with: @@ -22,24 +29,26 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Build Docker image + - name: Set outputs + id: vars env: BRANCH_NAME: ${{ github.ref_name }} - SHORT_HASH: ${{ github.sha }} run: | - # Build the image with the commit hash tag - docker build --build-arg BUILD_IDENTIFIER=${SHORT_HASH:0:5} -t gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5} . + echo branch_name="$BRANCH_NAME" | tee -a $GITHUB_OUTPUT + echo short_hash=$(git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT - # Tag the same image as "latest" - docker tag gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5} gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-latest - - - name: Push Docker images - env: - BRANCH_NAME: ${{ github.ref_name }} - SHORT_HASH: ${{ github.sha }} - run: | - docker push gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-${SHORT_HASH:0:5} - docker push gitea.7o7.cx/kittyteam/kittybe:${BRANCH_NAME}-latest + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: | + linux/amd64 + linux/arm64 + pull: true + push: true + tags: | + gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-${{ steps.vars.outputs.short_hash }} + gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-latest - name: Log out from registry if: always()