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 pull requests don't breake the container builds.
  • Loading branch information
bjoernricks committed Aug 23, 2022
1 parent b15ed18 commit 3145e06
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/container.yml
Expand Up @@ -2,13 +2,15 @@ name: Container Image Builds

on:
push:
branches: [ main ]
branches: [ main, stable, oldstable ]
tags: ["v*"]
pull_request:
branches: [ main, stable, oldstable ]
workflow_dispatch:

jobs:
build:
name: "Upload images for building gvm-libs"
name: Build Images
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -17,14 +19,15 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gvm-libs-build
images: ${{ github.repository }}-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
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 @@ -36,6 +39,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -45,14 +49,14 @@ 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 }}
labels: ${{ steps.meta.outputs.labels }}

production:
name: "Upload production image"
name: Production Images
runs-on: ubuntu-latest
needs: build
steps:
Expand All @@ -62,14 +66,15 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: greenbone/gvm-libs
images: ${{ github.repository }}
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
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 @@ -81,6 +86,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -89,15 +95,16 @@ 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 }}
labels: ${{ steps.meta.outputs.labels }}

trigger-related-projects:
needs: production
name: "Trigger update docker images in related projects"
if: github.event_name != 'pull_request'
name: Trigger update container images in related projects
runs-on: ubuntu-latest
steps:
- name: Trigger main openvas-scanner container image build
Expand Down

0 comments on commit 3145e06

Please sign in to comment.