From 646a4c085a7ad0db500c2674d1fc98a333608146 Mon Sep 17 00:00:00 2001 From: e7d Date: Thu, 28 Mar 2024 13:55:11 +0100 Subject: [PATCH] feat(): add GitHub actions to build Docker Image --- .github/workflows/docker-image.yml | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..96aa912 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,57 @@ +name: docker-image + +on: + push: + tags: + - "*" + branches: + - "main" + pull_request: + branches: + - "main" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + 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 Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and export + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + cache-from: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache + cache-to: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache,mode=max + push: true + tags: ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }} + - name: Push "tag" + if: github.ref_type == 'tag' + run: | + GITHUB_REF=${{ github.ref }} + TAG=${GITHUB_REF#refs/tags/} + docker buildx imagetools create \ + --tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG} \ + ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }} + - name: Push "latest" + if: github.ref == 'refs/heads/main' + run: | + docker buildx imagetools create \ + --tag ${{ vars.DOCKERHUB_IMAGE }}:latest \ + ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }} + - name: Update repo description + if: github.ref == 'refs/heads/main' + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ vars.DOCKERHUB_IMAGE }}