From cc96f669df9f1a65e6fc1e9f9afebb8136f21fce Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 8 Mar 2024 18:55:37 +0100 Subject: [PATCH] ci: Add image descriptions and source More information in case the image is consumed via different sources than the official one. Signed-off-by: Jan Kiszka --- .github/actions/docker-init/action.yml | 26 +++++++++++++++++++++++--- .github/workflows/master.yml | 3 ++- .github/workflows/next.yml | 3 ++- .github/workflows/release.yml | 3 ++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/actions/docker-init/action.yml b/.github/actions/docker-init/action.yml index 6b2d33ae..91927066 100644 --- a/.github/actions/docker-init/action.yml +++ b/.github/actions/docker-init/action.yml @@ -5,7 +5,7 @@ inputs: required: true deploy-token: required: true - cache-key: + image-name: required: true runs: @@ -42,13 +42,13 @@ runs: uses: actions/cache@v4 with: path: var-cache-apt - key: var-cache-apt-${{ env.DEBIAN_TAG }}-${{ inputs.cache-key }} + key: var-cache-apt-${{ env.DEBIAN_TAG }}-${{ inputs.image-name }} - name: Cache var-lib-apt id: cache-var-lib-apt uses: actions/cache@v4 with: path: var-lib-apt - key: var-lib-apt-${{ env.DEBIAN_TAG }}-${{ inputs.cache-key }} + key: var-lib-apt-${{ env.DEBIAN_TAG }}-${{ inputs.image-name }} - name: Inject var-cache-apt into docker uses: reproducible-containers/buildkit-cache-dance@v2.1.4 with: @@ -61,3 +61,23 @@ runs: cache-source: var-lib-apt cache-target: /var/lib/apt skip-extraction: ${{ steps.cache-var-lib-apt.outputs.cache-hit }} + - name: Define metadata + run: | + case ${{ inputs.image-name }} in + kas) + echo "IMAGE_DESCRIPTION=\"kas build environment for Yocto/OpenEmbedded projects\"" >> $GITHUB_ENV + ;; + kas-isar) + echo "IMAGE_DESCRIPTION=\"kas build environment for isar-based Debian projects\"" >> $GITHUB_ENV + ;; + esac + shell: bash + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + annotations: | + org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }} + org.opencontainers.image.licenses="MIT and others" + env: + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e128022b..5f1753c7 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -30,7 +30,7 @@ jobs: with: deploy-user: ${{ github.actor }} deploy-token: ${{ secrets.GITHUB_TOKEN }} - cache-key: ${{ matrix.image-name }} + image-name: ${{ matrix.image-name }} - name: Build ${{ matrix.image-name }} image uses: docker/build-push-action@v5 if: ${{ env.PUSH_MASTER }} @@ -44,3 +44,4 @@ jobs: provenance: mode=max,reproducible=true outputs: type=registry,rewrite-timestamp=true tags: ghcr.io/siemens/kas/${{ matrix.image-name }} + annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }} diff --git a/.github/workflows/next.yml b/.github/workflows/next.yml index 567f3cda..8575a759 100644 --- a/.github/workflows/next.yml +++ b/.github/workflows/next.yml @@ -76,7 +76,7 @@ jobs: with: deploy-user: ${{ github.actor }} deploy-token: ${{ secrets.GITHUB_TOKEN }} - cache-key: ${{ matrix.image-name }} + image-name: ${{ matrix.image-name }} - name: Build ${{ matrix.image-name }} image uses: docker/build-push-action@v5 @@ -105,3 +105,4 @@ jobs: provenance: mode=max,reproducible=true outputs: type=registry,rewrite-timestamp=true tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next + annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67e7a97c..5c0c2e03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: with: deploy-user: ${{ github.actor }} deploy-token: ${{ secrets.GITHUB_TOKEN }} - cache-key: ${{ matrix.image-name }} + image-name: ${{ matrix.image-name }} - name: Build ${{ matrix.image-name }} image uses: docker/build-push-action@v5 with: @@ -38,3 +38,4 @@ jobs: ghcr.io/siemens/kas/${{ matrix.image-name }} ghcr.io/siemens/kas/${{ matrix.image-name }}:${{ env.RELEASE_VERSION }} ghcr.io/siemens/kas/${{ matrix.image-name }}:latest-release + annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }}