Skip to content

Commit

Permalink
Change: Build container images for pull requests too
Browse files Browse the repository at this point in the history
Ensure that changes in pull requests don't break container image builds.
  • Loading branch information
bjoernricks committed Aug 23, 2022
1 parent 3c086d2 commit 54da597
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [ main, stable, oldstable, middleware ]
tags: ["v*"]
pull_request:
branches: [ main, stable, oldstable, middleware ]
workflow_dispatch:
repository_dispatch:

Expand All @@ -19,21 +21,23 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/openvas-scanner
images: ${{ github.repository }}
labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=debian/stable-slim
org.opencontainers.image.base.name=greenbone/gvm-libs
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: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -46,7 +50,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
push: true
push: ${{ github.event_name != 'pull_request' }}
file: .docker/prod.Dockerfile
build-args: |
REPOSITORY=${{ github.repository }}
Expand All @@ -64,21 +68,23 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/openvas-scanner-build
images: ${{ github.repository }}-build
labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=debian/stable-slim
org.opencontainers.image.base.name=greenbone/gvm-libs
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: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -92,7 +98,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
push: true
push: ${{ github.event_name != 'pull_request' }}
file: .docker/build.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
Expand Down

0 comments on commit 54da597

Please sign in to comment.