Skip to content

Commit

Permalink
add labels to container images (#95)
Browse files Browse the repository at this point in the history
* add labels to container images

* fix shell cmd

* use tee --append for github outputs
  • Loading branch information
briantist authored Sep 29, 2023
1 parent bffe509 commit 2ddf34f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2ddf34f

Please sign in to comment.