From 6fb1fba85d147806447e81b82134f453d4371a0e Mon Sep 17 00:00:00 2001 From: Konstantin Chukhlomin Date: Mon, 2 Oct 2023 21:10:22 -0400 Subject: [PATCH] feat: Docker multiarch --- .github/workflows/main.yml | 24 +++++------------------- .github/workflows/release.yml | 19 +++++++++---------- Dockerfile | 2 +- README.md | 2 +- action.yml | 2 +- 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5684790..66fbacd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: push: branches: - main - + env: DOCKER_IMAGE: chuhlomin/render-template @@ -15,29 +15,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Login to CR - uses: docker/login-action@v2 + - name: Build and push Docker image + uses: chuhlomin/actions/docker-build-push@main with: username: chuhlomin password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.DOCKER_IMAGE }} - tags: latest - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - push: true + image_name: ${{ env.DOCKER_IMAGE }} tags: | - ${{ steps.meta.outputs.tags }} ${{ env.DOCKER_IMAGE }}:${{ github.sha }} - labels: ${{ steps.meta.outputs.labels }} + ${{ env.DOCKER_IMAGE }}:latest - name: Test action uses: ./ # Uses an action in the root directory diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd05c24..405075f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,18 +12,17 @@ jobs: release: runs-on: ubuntu-latest steps: - - name: Login to CR - uses: docker/login-action@v2 - with: - username: chuhlomin - password: ${{ secrets.DOCKER_PASSWORD }} + - name: Checkout + uses: actions/checkout@v3 - name: Get the tag id: get_tag run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT - - name: Tag & push image - run: | - docker pull ${{ env.DOCKER_IMAGE }}:${{ github.sha }} - docker tag ${{ env.DOCKER_IMAGE }}:${{ github.sha }} ${{ env.DOCKER_IMAGE }}:${{ steps.get_tag.outputs.tag }} - docker push ${{ env.DOCKER_IMAGE }}:${{ steps.get_tag.outputs.tag }} + - name: Build and push Docker image + uses: chuhlomin/actions/docker-build-push@main + with: + username: chuhlomin + password: ${{ secrets.DOCKER_PASSWORD }} + image_name: ${{ env.DOCKER_IMAGE }} + tags: ${{ env.DOCKER_IMAGE }}:${{ steps.get_tag.outputs.tag }} diff --git a/Dockerfile b/Dockerfile index 9d54c21..6ca2042 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17 as build-env +FROM --platform=$BUILDPLATFORM golang:1.17 as build-env WORKDIR /go/src/app ADD . /go/src/app diff --git a/README.md b/README.md index 748a3fb..bee4ee3 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ jobs: - name: Render template id: render_template - uses: chuhlomin/render-template@v1.7 + uses: chuhlomin/render-template@v1.8 with: template: kube.template.yml vars: | diff --git a/action.yml b/action.yml index 1d9ad08..35eb3c2 100644 --- a/action.yml +++ b/action.yml @@ -34,4 +34,4 @@ outputs: runs: using: docker - image: 'docker://chuhlomin/render-template:v1.7' + image: 'docker://chuhlomin/render-template:v1.8'