From 0f542ac4e543e0b402f3290beb9271464d890264 Mon Sep 17 00:00:00 2001 From: Gavin Mogan Date: Wed, 6 Nov 2024 09:01:42 -0800 Subject: [PATCH] [DOCKER] Use Gha docker metadata actions to setup all the github actions (#1116) --- .github/workflows/package-gui.yaml | 40 ++++++++++++++++++-------- .github/workflows/package-ubuntu.yaml | 40 ++++++++++++++++++-------- .github/workflows/package.yaml | 41 +++++++++++++++++++-------- 3 files changed, 85 insertions(+), 36 deletions(-) diff --git a/.github/workflows/package-gui.yaml b/.github/workflows/package-gui.yaml index ad2e6f4fc..0b9ac86c5 100644 --- a/.github/workflows/package-gui.yaml +++ b/.github/workflows/package-gui.yaml @@ -247,7 +247,7 @@ jobs: # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') echo IMAGE_ID=${IMAGE_ID} - + echo ::set-output name=IMAGE_ID::${IMAGE_ID} - name: Get the version @@ -260,17 +260,33 @@ jobs: # Use Docker `latest` tag convention [ "$VERSION" == "master" ] && VERSION=latest echo VERSION=${VERSION} - + echo ::set-output name=VERSION::${VERSION} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.formatted-image_id.outputs.IMAGE_ID }} + labels: | + runnumber=${{ github.run_number }} + maintainer=${{ github.repository_owner }} + org.opencontainers.image.authors=${{ github.repository_owner }} + org.opencontainers.image.vendor=${{ github.repository_owner }} + org.opencontainers.image.documentation=https://ytdl-sub.readthedocs.io/ + tags: | + type=raw,value=${{ steps.formatted_version.outputs.VERSION }} + type=raw,value=${{ needs.version.outputs.pypi_version }} + - name: Build Docker Image and push to registry - run: | - docker buildx build --push \ - --platform=linux/amd64,linux/arm64 \ - --cache-from=type=local,src=/tmp/build-cache/amd64 \ - --cache-from=type=local,src=/tmp/build-cache/arm64 \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:${{ steps.formatted_version.outputs.VERSION }} \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:${{ needs.version.outputs.pypi_version }} \ - --label "runnumber=${GITHUB_RUN_ID}" \ - --file docker/Dockerfile.gui \ - docker/ \ No newline at end of file + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: "docker/" + file: "docker/Dockerfile.gui" + cache-from: | + type=local,src=/tmp/build-cache/amd64 + type=local,src=/tmp/build-cache/arm64 diff --git a/.github/workflows/package-ubuntu.yaml b/.github/workflows/package-ubuntu.yaml index 3e1e30ccb..40d4e0fc4 100644 --- a/.github/workflows/package-ubuntu.yaml +++ b/.github/workflows/package-ubuntu.yaml @@ -247,7 +247,7 @@ jobs: # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') echo IMAGE_ID=${IMAGE_ID} - + echo ::set-output name=IMAGE_ID::${IMAGE_ID} - name: Get the version @@ -260,17 +260,33 @@ jobs: # Use Docker `latest` tag convention [ "$VERSION" == "master" ] && VERSION=latest echo VERSION=${VERSION} - + echo ::set-output name=VERSION::${VERSION} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.formatted-image_id.outputs.IMAGE_ID }} + labels: | + runnumber=${{ github.run_number }} + maintainer=${{ github.repository_owner }} + org.opencontainers.image.authors=${{ github.repository_owner }} + org.opencontainers.image.vendor=${{ github.repository_owner }} + org.opencontainers.image.documentation=https://ytdl-sub.readthedocs.io/ + tags: | + type=raw,value=ubuntu-${{ steps.formatted_version.outputs.VERSION }} + type=raw,value=ubuntu-${{ needs.version.outputs.pypi_version }} + - name: Build Docker Image and push to registry - run: | - docker buildx build --push \ - --platform=linux/amd64,linux/arm64 \ - --cache-from=type=local,src=/tmp/build-cache/amd64 \ - --cache-from=type=local,src=/tmp/build-cache/arm64 \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:ubuntu-${{ steps.formatted_version.outputs.VERSION }} \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:ubuntu-${{ needs.version.outputs.pypi_version }} \ - --label "runnumber=ubuntu-${GITHUB_RUN_ID}" \ - --file docker/Dockerfile.ubuntu \ - docker/ \ No newline at end of file + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: "docker/" + file: "docker/Dockerfile.ubuntu" + cache-from: | + type=local,src=/tmp/build-cache/amd64 + type=local,src=/tmp/build-cache/arm64 diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 33be9483e..53d9da7ae 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -241,7 +241,7 @@ jobs: # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') echo IMAGE_ID=${IMAGE_ID} - + echo ::set-output name=IMAGE_ID::${IMAGE_ID} - name: Get the version @@ -254,16 +254,33 @@ jobs: # Use Docker `latest` tag convention [ "$VERSION" == "master" ] && VERSION=latest echo VERSION=${VERSION} - + echo ::set-output name=VERSION::${VERSION} - - name: Build Docker Image and push to registry - run: | - docker buildx build --push \ - --platform=linux/amd64,linux/arm64 \ - --cache-from=type=local,src=/tmp/build-cache/amd64 \ - --cache-from=type=local,src=/tmp/build-cache/arm64 \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:${{ steps.formatted_version.outputs.VERSION }} \ - --tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:${{ needs.version.outputs.pypi_version }} \ - --label "runnumber=${GITHUB_RUN_ID}" \ - docker/ \ No newline at end of file + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.formatted-image_id.outputs.IMAGE_ID }} + labels: | + runnumber=${{ github.run_number }} + maintainer=${{ github.repository_owner }} + org.opencontainers.image.authors=${{ github.repository_owner }} + org.opencontainers.image.vendor=${{ github.repository_owner }} + org.opencontainers.image.documentation=https://ytdl-sub.readthedocs.io/ + tags: | + type=raw,value=${{ steps.formatted_version.outputs.VERSION }} + type=raw,value=${{ needs.version.outputs.pypi_version }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: "docker/" + cache-from: | + type=local,src=/tmp/build-cache/amd64 + type=local,src=/tmp/build-cache/arm64