12
12
13
13
env :
14
14
REGISTRY : ghcr.io
15
- IMAGE_NAME : utbot_java_cli
16
- DOCKERFILE_PATH : docker/Dockerfile_java_cli
17
15
18
16
jobs :
19
17
build-and-run-tests :
@@ -32,36 +30,40 @@ jobs:
32
30
publish-cli-image :
33
31
needs : build-and-run-tests
34
32
if : ${{ github.event_name == 'push' }}
33
+ strategy :
34
+ fail-fast : false # force to execute all jobs even though some of them have failed
35
+ matrix :
36
+ configuration :
37
+ - image_name : utbot_java_cli
38
+ directory : utbot-cli
39
+ extra_options : " "
40
+ - image_name : utbot_js_cli
41
+ directory : utbot-cli-js
42
+ extra_options : " -PbuildType=ALL"
43
+ # we can't use utbot_python_cli image name because of the bug while pushing image
44
+ # ERROR: unexpected status: 403 Forbidden
45
+ - image_name : utbot_py_cli
46
+ directory : utbot-cli-python
47
+ extra_options : " "
35
48
runs-on : ubuntu-20.04
36
49
container : unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
37
50
steps :
38
- - name : Print environment variables
39
- run : printenv
40
-
41
51
- uses : actions/checkout@v3
42
52
53
+ # "You can make an environment variable available to any subsequent steps in a workflow job by
54
+ # defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
43
55
- name : Set environment variables
44
56
run : |
45
- # "You can make an environment variable available to any subsequent steps in a workflow job by
46
- # defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
47
57
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV
48
-
49
- - name : Build UTBot Java CLI
50
- run : |
51
- cd utbot-cli
52
- gradle build --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -x test -PsemVer=${{ env.VERSION }}
53
- - name : Set docker tag
54
- run :
55
- # "You can make an environment variable available to any subsequent steps in a workflow job by
56
- # defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
57
- echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV
58
+ echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-$(echo -n ${GITHUB_SHA} | cut -c 1-7)" >> $GITHUB_ENV
58
59
59
- - name : Log in to the Container registry
60
- uses : docker/login-action@v2
61
- with :
62
- registry : ${{ env.REGISTRY }}
63
- username : ${{ github.actor }}
64
- password : ${{ secrets.GITHUB_TOKEN }}
60
+ - name : Print environment variables
61
+ run : printenv
62
+
63
+ - name : Build UTBot CLI
64
+ run : |
65
+ cd ${{ matrix.configuration.directory }}
66
+ gradle build --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -x test -PsemVer=${{ env.VERSION }}
65
67
66
68
- name : Set up Docker Buildx
67
69
uses : docker/setup-buildx-action@v2
@@ -71,32 +73,45 @@ jobs:
71
73
driver-opts : |
72
74
image=moby/buildkit:v0.10.6
73
75
76
+ - name : Log in to the Container registry
77
+ uses : docker/login-action@v2
78
+ with :
79
+ registry : ${{ env.REGISTRY }}
80
+ username : ${{ github.actor }}
81
+ password : ${{ secrets.GITHUB_TOKEN }}
82
+
74
83
- name : Cache Docker layers
75
84
uses : actions/cache@v3
76
85
with :
77
86
path : /tmp/.buildx-cache
78
- key : ${{ runner.os }}-buildx-${{ github.sha }}
87
+ key : ${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-${{ github.sha }}
79
88
restore-keys : |
80
- ${{ runner.os }}-buildx-
89
+ ${{ runner.os }}-buildx-${{ matrix.configuration.image_name }}-
90
+
81
91
- name : Docker meta
82
92
id : meta
83
93
uses : docker/metadata-action@v3
84
94
with :
85
- images : ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
95
+ images : ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.configuration.image_name }}
86
96
tags : |
87
97
type=raw,value=${{ env.DOCKER_TAG }}
88
- - name : Docker Buildx (build and push)
89
- run : |
90
- docker buildx build \
91
- -f ${{ env.DOCKERFILE_PATH }} \
92
- --cache-from "type=local,src=/tmp/.buildx-cache" \
93
- --cache-to "type=local,dest=/tmp/.buildx-cache-new" \
94
- --tag ${{ steps.meta.outputs.tags }} \
95
- --build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
96
- --push .
97
- # Temp fix
98
- # https://github.com/docker/build-push-action/issues/252
99
- # https://github.com/moby/buildkit/issues/1896
98
+
99
+ - name : Build and push
100
+ uses : docker/build-push-action@v4
101
+ with :
102
+ context : .
103
+ push : true
104
+ tags : |
105
+ ${{ steps.meta.outputs.tags }}
106
+ cache-from : type=local,src=/tmp/.buildx-cache
107
+ cache-to : type=local,dest=/tmp/.buildx-cache-new
108
+ file : ${{ matrix.configuration.directory }}/Dockerfile
109
+ build-args : |
110
+ ARTIFACT_PATH=${{ matrix.configuration.directory }}/build/libs/${{ matrix.configuration.directory }}-${{ env.VERSION }}.jar
111
+
112
+ # Temp fix
113
+ # https://github.com/docker/build-push-action/issues/252
114
+ # https://github.com/moby/buildkit/issues/1896
100
115
- name : Move cache
101
116
run : |
102
117
rm -rf /tmp/.buildx-cache
0 commit comments