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 c080bdd commit 3c086d2
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@ jobs:
steps:
- name: Checkout
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/openvas-scanner
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: Login to DockerHub
uses: docker/login-action@v2
with:
Expand All @@ -32,29 +47,43 @@ jobs:
with:
context: .
push: true
tags: ${{ steps.container.outputs.image-tags }}
platforms: linux/amd64,linux/arm64
file: .docker/prod.Dockerfile
build-args: |
REPOSITORY=${{ github.repository }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build:
name: "Upload images for building openvas-scanner"
runs-on: ubuntu-latest
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/openvas-scanner-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: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: echo "Build and push ${{ steps.container.outputs.image-tags }}"
- run: echo "Build and push ${{ steps.meta.outputs.tags }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -64,6 +93,7 @@ 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 }}

0 comments on commit 3c086d2

Please sign in to comment.