-
Notifications
You must be signed in to change notification settings - Fork 331
76 lines (73 loc) · 2.28 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Build and push latest image
on:
push:
branches:
- main
- stable
schedule:
# We run it every 4 hours, starting at 03:15.
# Note that this will only update the 'latest' tag (not the 'stable' tag).
# Ideally, we would update the image every time the base image (p4lang/pi)
# is updated, but we deem this good enough.
- cron: '15 3-23/4 * * *' # "At minute 15 past every 4th hour from 3 through 23."
jobs:
build:
if: ${{ github.repository == 'p4lang/behavioral-model' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Determine Docker image tag
id: get-tag
shell: bash
run: |
TAG=""
if [[ "$GITHUB_REF" =~ "main" ]]; then
TAG="latest"
elif [[ "$GITHUB_REF" =~ "stable" ]]; then
TAG="stable"
else
echo "Invalid Github ref $GITHUB_REF"
exit 1
fi
echo "Tag is $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image to registry
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: p4lang/behavioral-model:${{ steps.get-tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-no-pi:
if: ${{ github.repository == 'p4lang/behavioral-model' && github.ref == 'refs/heads/main' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image to registry
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.noPI
push: true
tags: p4lang/behavioral-model:no-pi
cache-from: type=gha
cache-to: type=gha,mode=max