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

(cherry picked from commit 8aa4ec5)
  • Loading branch information
bjoernricks committed Aug 23, 2022
1 parent f7c6b76 commit 934b897
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,36 @@ on:

jobs:
images:
name: Build and upload container images
name: Production Images
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Gather container image tags
uses: greenbone/actions/container-image-tags@v1
id: container
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup container meta information
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=greenbone/gsad
flavor: latest=false # no latest container tag for git tags
tags: |
# create container tag for git tags
type=ref,event=tag
type=ref,event=pr
# 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 @@ -31,6 +47,7 @@ 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 }}

0 comments on commit 934b897

Please sign in to comment.