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