From ec532294f41cae12e59f1aabc992294aa1dc2099 Mon Sep 17 00:00:00 2001 From: Simon L Date: Wed, 27 Sep 2023 18:03:17 +0200 Subject: [PATCH] adjust build action to only be one process Signed-off-by: Simon L --- .github/workflows/build_image.yml | 54 ------------------------- .github/workflows/docker-build.yml | 42 +++++++++++++++++++ .github/workflows/promote-to-beta.yml | 32 --------------- .github/workflows/promote-to-latest.yml | 30 -------------- 4 files changed, 42 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/build_image.yml create mode 100644 .github/workflows/docker-build.yml delete mode 100644 .github/workflows/promote-to-beta.yml delete mode 100644 .github/workflows/promote-to-latest.yml diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml deleted file mode 100644 index 5a3881e..0000000 --- a/.github/workflows/build_image.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build docker image - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - platform: [ - {arch: 'linux/amd64', tag: 'develop'}, - {arch: 'linux/arm64', tag: 'develop-arm64'}] - container: [ - {name: 'aio-fail2ban', context: './'}] - - steps: - - name: Check out the repo - 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 DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker metadata - id: metadata - uses: docker/metadata-action@v5 - with: - images: | - szaimen/${{ matrix.container.name }} - tags: | - ${{ matrix.platform.tag }} - - - name: Build docker image and push to dockerhub - uses: docker/build-push-action@v5 - with: - context: ${{ matrix.container.context }} - platforms: ${{matrix.platform.arch}} - no-cache: true - push: true - tags: ${{ steps.metadata.outputs.tags }} - provenance: false - # Needed since when on default 'application/vnd.oci.image.index.v1+json' is used which does not work with "docker manifest create" (multiarch) - # TODO make it work with default value \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..7422b75 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,42 @@ +name: Docker Build and Publish + +on: + workflow_dispatch: + inputs: + tagName: + description: "Tag name" + required: true + default: 'latest' + +jobs: + push_to_registry: + runs-on: ubuntu-latest + + name: Build docker image and push to dockerhub + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build container image + uses: docker/build-push-action@v2 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: './' + no-cache: true + file: 'Dockerfile' + tags: szaimen:${{ github.event.inputs.tagName }} + provenance: false diff --git a/.github/workflows/promote-to-beta.yml b/.github/workflows/promote-to-beta.yml deleted file mode 100644 index 146b56a..0000000 --- a/.github/workflows/promote-to-beta.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Promote to beta - -on: - workflow_dispatch: - -jobs: - promote_to_latest: - runs-on: ubuntu-latest - name: Promote from develop to beta - - strategy: - fail-fast: false - matrix: - name: ['aio-fail2ban'] - - steps: - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Promote images from develop to beta (create multiarch) - run: | - set -x - AIO_NAME=${{ matrix.name }} - DOCKER_HUB_ORG=szaimen - set +x - - # create multiarch image - docker manifest create "$DOCKER_HUB_ORG"/$AIO_NAME\:beta -a "$DOCKER_HUB_ORG"/$AIO_NAME\:develop -a "$DOCKER_HUB_ORG"/$AIO_NAME\:develop-arm64 - docker manifest push "$DOCKER_HUB_ORG"/$AIO_NAME\:beta diff --git a/.github/workflows/promote-to-latest.yml b/.github/workflows/promote-to-latest.yml deleted file mode 100644 index 979cba9..0000000 --- a/.github/workflows/promote-to-latest.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Promote to latest - -on: - workflow_dispatch: - -jobs: - promote_to_latest: - runs-on: ubuntu-latest - name: Promote from beta to latest - - strategy: - fail-fast: false - matrix: - name: ['aio-fail2ban'] - - steps: - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Promote images from beta to latest - run: | - set -x - AIO_NAME=${{ matrix.name }} - DOCKER_HUB_ORG=szaimen - set +x - - docker buildx imagetools create --tag "$DOCKER_HUB_ORG"/$AIO_NAME\:latest "$DOCKER_HUB_ORG"/$AIO_NAME\:beta