Skip to content

Commit

Permalink
Build (only) container images for new PRs (#3788)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbolvansky committed Dec 19, 2022
1 parent 8876cec commit 21032b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci-container-image.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 }}
Expand All @@ -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

0 comments on commit 21032b5

Please sign in to comment.