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 5943b5c commit e02cbf7
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 @@ -14,9 +14,24 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Gather container image tags
id: container
uses: greenbone/actions/container-image-tags@v1
- name: Setup container meta information
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gvmd
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 Docker Registry
uses: docker/login-action@v2
with:
Expand All @@ -31,27 +46,41 @@ 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 }}

upload-build:
name: "Upload images for building gvmd"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Gather container image names
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/gvmd-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 @@ -61,9 +90,10 @@ jobs:
with:
context: .
push: true
tags: ${{ steps.container.outputs.image-tags }}
file: .docker/build.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Trigger libtheia container build
run: |
curl -X POST https://api.github.com/repos/greenbone/libtheia/actions/workflows/container.yml/dispatches \
Expand Down

0 comments on commit e02cbf7

Please sign in to comment.