From 2ddf34f13e7d1e514f26a56a3e5bec9af82d9936 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Fri, 29 Sep 2023 19:04:55 -0400 Subject: [PATCH] add labels to container images (#95) * add labels to container images * fix shell cmd * use tee --append for github outputs --- .github/workflows/test.yml | 17 ++++++++++++++--- Dockerfile | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34b8b0f..bed04d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,9 +49,9 @@ jobs: id: setvars run: | VER_TAG=${GITHUB_REF/refs\/tags\/v/} - echo "relver=${VER_TAG}" >> $GITHUB_OUTPUT - echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT - echo "changelogver=v${VER_TAG//\./-}" >> $GITHUB_OUTPUT + echo "relver=${VER_TAG}" | tee --append $GITHUB_OUTPUT + echo "branch=${GITHUB_REF#refs/heads/}" | tee --append $GITHUB_OUTPUT + echo "changelogver=v${VER_TAG//\./-}" | tee --append $GITHUB_OUTPUT - name: Coverage uses: codecov/codecov-action@v3 @@ -61,6 +61,8 @@ jobs: permissions: contents: read runs-on: ubuntu-latest + outputs: + container-description: ${{ steps.description.outputs.container-description }} steps: - uses: actions/checkout@v4 with: @@ -84,6 +86,12 @@ jobs: - name: Run container run: docker run --rm galactory --help + - name: Extract container description + id: description + run: | + DESC=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.description" }}' galactory) + echo "container-description=$DESC" | tee --append $GITHUB_OUTPUT + - name: Build arm64 uses: docker/build-push-action@v5 with: @@ -159,9 +167,12 @@ jobs: push: ${{ github.event_name == 'push' }} context: . platforms: linux/amd64,linux/arm64 + labels: | + org.opencontainers.image.source=${{ github.repositoryUrl }} tags: | ${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || needs.test.outputs.branch }} ${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && needs.test.outputs.relver || github.sha }} + outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ needs.build.outputs.container-description }} pypi_release: needs: [test, build] diff --git a/Dockerfile b/Dockerfile index f6793ca..63b483e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,10 @@ RUN pip install ./galactory FROM python:3.11-slim as final +LABEL org.opencontainers.image.title="galactory" +LABEL org.opencontainers.image.licenses="GPL-3.0-or-later" +LABEL org.opencontainers.image.description="galactory: Ansible Galaxy proxy using Artifactory as a backend." + COPY --from=build /venv /venv ENV PATH=/venv/bin:$PATH