5
5
branches : [ main ]
6
6
tags :
7
7
- v*
8
+ pull_request :
8
9
9
10
jobs :
10
11
test :
@@ -20,29 +21,56 @@ jobs:
20
21
run : sudo ./.github/install-etcd.sh
21
22
- name : Build with Maven
22
23
run : mvn -B package --file pom.xml
24
+
23
25
build :
24
26
needs : test
25
27
runs-on : ubuntu-latest
28
+
26
29
env :
27
30
IMAGE_NAME : kserve/modelmesh
31
+
28
32
steps :
29
- - uses : actions/checkout@v2
30
- - name : Build and push runtime image
31
- run : |
32
- GIT_COMMIT=$(git rev-parse HEAD)
33
- BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)
33
+ - uses : actions/checkout@v2
34
+
35
+ - name : Setup QEMU
36
+ uses : docker/setup-qemu-action@v2
37
+
38
+ - name : Setup Docker Buildx
39
+ uses : docker/setup-buildx-action@v2
40
+
41
+ - name : Login to DockerHub
42
+ if : github.event_name == 'push'
43
+ uses : docker/login-action@v2
44
+ with :
45
+ username : ${{ secrets.DOCKER_USER }}
46
+ password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
47
+
48
+ - name : Export version variables
49
+ run : |
50
+ GIT_COMMIT=$(git rev-parse HEAD)
51
+ BUILD_ID=$(date '+%Y%m%d')-$(git rev-parse HEAD | cut -c -5)
34
52
35
- # Strip git ref prefix from version
36
- VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
53
+ # Strip git ref prefix from version
54
+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
37
55
38
- # Use Docker `latest` tag convention
39
- [ "$VERSION" == "main" ] && VERSION=latest
40
- echo $VERSION
56
+ # Use Docker `latest` tag convention
57
+ [ "$VERSION" == "main" ] && VERSION=latest
41
58
42
- docker build -t ${{ env.IMAGE_NAME }}:$VERSION \
43
- --build-arg imageVersion=$VERSION \
44
- --build-arg buildId=${BUILD_ID} \
45
- --build-arg commitSha=${GIT_COMMIT} .
59
+ echo "GIT_COMMIT=$GIT_COMMIT" >> $GITHUB_ENV
60
+ echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV
61
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
46
62
47
- docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }}
48
- docker push ${{ env.IMAGE_NAME }}:$VERSION
63
+ - name : Build and push
64
+ uses : docker/build-push-action@v3
65
+ with :
66
+ # for linux/s390x, maven errors due to missing io.grpc:protoc-gen-grpc-java:exe:linux-s390_64:1.51.1
67
+ platforms : linux/amd64,linux/arm64/v8,linux/ppc64le
68
+ pull : true
69
+ cache-from : type=gha
70
+ cache-to : type=gha,mode=max
71
+ push : ${{ github.event_name == 'push' }}
72
+ tags : ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
73
+ build-args : |
74
+ imageVersion=${{ env.VERSION }}
75
+ buildId=${{ env.BUILD_ID }}
76
+ commitSha=${{ env.GIT_COMMIT }}
0 commit comments