From 8d01a299111e44fe4cdee1390abc577f2cd6a6cc Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Sat, 25 Jan 2025 18:51:16 +0100 Subject: [PATCH] unify all build files --- .github/workflows/latest.yml | 58 ++++++++++++++++++++++++++------ .github/workflows/nightly.yml | 2 +- .github/workflows/releases.yml | 60 +++++++++++++++++++++++++++------- 3 files changed, 98 insertions(+), 22 deletions(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 898fcdb..18bffd5 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -8,9 +8,12 @@ on: - '*' workflow_dispatch: +# set docker tag for all steps +env: + DOCKERTAG: latest + jobs: docker_build: - name: docker runs-on: ${{ matrix.target.runs }} permissions: packages: write @@ -43,20 +46,55 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.PTA }} - - name: Build to hub.docker.com + - name: Build and Push uses: docker/build-push-action@v6 with: push: true file: Dockerfile.omd-labs-${{ matrix.os }} build-args: OMD_VERSION=${{ github.ref }} - tags: consol/omd-labs-${{ matrix.os }}:latest + tags: | + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-${{ matrix.target.platform }} + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-${{ matrix.target.platform }} platforms: linux/${{ matrix.target.platform }} - - name: Build to ghcr.io - uses: docker/build-push-action@v6 + manifest: + runs-on: ubuntu-24.04 + needs: docker_build + permissions: + packages: write + contents: read + strategy: + fail-fast: false + matrix: + os: + - rocky + - debian + steps: + - uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 with: - push: true - file: Dockerfile.omd-labs-${{ matrix.os }} - build-args: OMD_VERSION=${{ github.ref }} - tags: ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:latest - platforms: linux/${{ matrix.target.platform }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.PTA }} + + - name: push manifest to dockerhub + run: | + docker manifest create consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-amd64 \ + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-arm64 + docker manifest push consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} + + - name: push manifest to github + run: | + docker manifest create ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-amd64 \ + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-arm64 + docker manifest push ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9b7a38f..31007b5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -97,4 +97,4 @@ jobs: docker manifest create ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-amd64 \ ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-arm64 - docker manifest push ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ No newline at end of file + docker manifest push ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 3e24213..a4b7d85 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -8,9 +8,12 @@ on: - '*' workflow_dispatch: +# set docker tag for all steps +env: + DOCKERTAG: ${{ github.head_ref || github.ref_name }} + jobs: docker_build: - name: docker runs-on: ${{ matrix.target.runs }} permissions: packages: write @@ -43,20 +46,55 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.PTA }} - - name: Build to hub.docker.com + - name: Build and Push uses: docker/build-push-action@v6 with: push: true file: Dockerfile.omd-labs-${{ matrix.os }} - build-args: OMD_VERSION=${{ env.BRANCH_NAME }} - tags: consol/omd-labs-${{ matrix.os }}:${{ env.BRANCH_NAME }} + build-args: OMD_VERSION=${{ github.ref }} + tags: | + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-${{ matrix.target.platform }} + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-${{ matrix.target.platform }} platforms: linux/${{ matrix.target.platform }} - - name: Build to ghcr.io - uses: docker/build-push-action@v6 + manifest: + runs-on: ubuntu-24.04 + needs: docker_build + permissions: + packages: write + contents: read + strategy: + fail-fast: false + matrix: + os: + - rocky + - debian + steps: + - uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 with: - push: true - file: Dockerfile.omd-labs-${{ matrix.os }} - build-args: OMD_VERSION=${{ github.ref }} - tags: ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.BRANCH_NAME }} - platforms: linux/${{ matrix.target.platform }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.PTA }} + + - name: push manifest to dockerhub + run: | + docker manifest create consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-amd64 \ + consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-arm64 + docker manifest push consol/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} + + - name: push manifest to github + run: | + docker manifest create ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }} \ + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-amd64 \ + ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}-arm64 + docker manifest push ghcr.io/consol/omd-labs-docker/omd-labs-${{ matrix.os }}:${{ env.DOCKERTAG }}