Skip to content

Commit

Permalink
Change: Use docker/meta-action for container tags and labels
Browse files Browse the repository at this point in the history
Use the docker/meta-action for setting container labels and tags. This
action is much more flexible then our own container-image-tags action.
  • Loading branch information
bjoernricks committed Aug 22, 2022
1 parent c91ea6d commit b15ed18
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Find reference branch
uses: greenbone/actions/container-image-tags@v1
id: container
- name: Setup container meta information
id: meta
uses: docker/metadata-action@v4
with:
image-name: ${{ github.repository }}-build
images: greenbone/gvm-libs-build
labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=debian/stable-slim
flavor: latest=false # no latest container tag for git tags
tags: |
# create container tag for git tags
type=ref,event=tag
# use latest for stable branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
type=raw,value=oldstable,enable=${{ github.ref == format('refs/heads/{0}', 'oldstable') }}
# use unstable for main branch
type=raw,value=unstable,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -33,9 +46,10 @@ jobs:
with:
context: .
push: true
tags: ${{ steps.container.outputs.image-tags }}
platforms: linux/amd64,linux/arm64
file: .docker/build.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

production:
name: "Upload production image"
Expand All @@ -44,9 +58,24 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Gather container image tags
uses: greenbone/actions/container-image-tags@v1
id: container
- name: Setup container meta information
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gvm-libs
labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=debian/stable-slim
flavor: latest=false # no latest container tag for git tags
tags: |
# create container tag for git tags
type=ref,event=tag
# use latest for stable branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
type=raw,value=oldstable,enable=${{ github.ref == format('refs/heads/{0}', 'oldstable') }}
# use unstable for main branch
type=raw,value=unstable,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -61,9 +90,10 @@ jobs:
with:
context: .
push: true
tags: ${{ steps.container.outputs.image-tags }}
platforms: linux/amd64,linux/arm64
file: .docker/prod.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

trigger-related-projects:
needs: production
Expand Down

0 comments on commit b15ed18

Please sign in to comment.