From 21032b5afc81ff849fd5c6144e39de691cb65f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?= Date: Mon, 19 Dec 2022 11:33:48 +0100 Subject: [PATCH] Build (only) container images for new PRs (#3788) --- .github/workflows/ci-container-image.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-container-image.yml b/.github/workflows/ci-container-image.yml index 5409f339967..b57867c05fd 100644 --- a/.github/workflows/ci-container-image.yml +++ b/.github/workflows/ci-container-image.yml @@ -1,9 +1,10 @@ -name: Build and push latest image to container registry +name: container-image on: push: - branches: - - main + branches: [ main ] + pull_request: + branches: [ main ] schedule: # Ideally, we would update the image every time the base image # (p4lang/behavioral-model) is updated, this is good enough. @@ -31,14 +32,14 @@ jobs: if [[ "$GITHUB_REF" =~ "main" ]]; then TAG="latest" else - echo "Invalid Github ref $GITHUB_REF" - exit 1 + TAG=${GITHUB_REF////_} fi echo "Tag is $TAG" echo "::set-output name=tag::$TAG" - 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@v1 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -47,7 +48,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: p4lang/p4c:${{ steps.get-tag.outputs.tag }} cache-from: type=gha cache-to: type=gha,mode=max