From 2782ed8cb1f3c0710bb3340ccd01e9cee940a7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 22 Aug 2022 15:56:53 +0200 Subject: [PATCH] Change: Run container image builds also for pull requests Ensure that container builds are successfull in pull requests too. This avoids adding changes to a PR that will break the container image builds. --- .github/workflows/container.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 0243d9308..cd3bdb88a 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -2,8 +2,10 @@ name: Container Image Builds on: push: - branches: [ main ] + branches: [ main, stable, oldstable ] tags: ["v*"] + pull_request: + branches: [ main, stable, oldstable ] workflow_dispatch: repository_dispatch: @@ -18,7 +20,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: greenbone/gvmd + images: ${{ github.repository }} labels: | org.opencontainers.image.vendor=Greenbone org.opencontainers.image.base.name=debian/stable-slim @@ -26,6 +28,7 @@ jobs: 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') }} @@ -33,6 +36,7 @@ jobs: # 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 }} @@ -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 }} @@ -61,7 +65,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: greenbone/gvmd-build + images: ${{ github.repository }}-build labels: | org.opencontainers.image.vendor=Greenbone org.opencontainers.image.base.name=debian/stable-slim @@ -69,6 +73,7 @@ jobs: 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') }} @@ -76,6 +81,7 @@ jobs: # 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 }} @@ -89,12 +95,13 @@ 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 }} - name: Trigger libtheia container build + if: github.event_name != 'pull_request' run: | curl -X POST https://api.github.com/repos/greenbone/libtheia/actions/workflows/container.yml/dispatches \ -H "Accept: application/vnd.github.v3+json" \