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 changes in pull requests don't break the container image builds.

(cherry picked from commit cb20d2e)
  • Loading branch information
bjoernricks committed Aug 24, 2022
1 parent b5d0f62 commit ccd85d0
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 ]
tags: ["v*"]
pull_request:
branches: [ main, stable, oldstable ]
workflow_dispatch:
repository_dispatch:

Expand All @@ -18,21 +20,23 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gsad
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 Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -45,7 +49,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
push: true
push: ${{ github.event_name != 'pull_request' }}
file: .docker/prod.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
Expand All @@ -61,14 +65,15 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gsad-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') }}
Expand All @@ -78,6 +83,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -91,7 +97,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 ccd85d0

Please sign in to comment.