|
5 | 5 | branches: [main]
|
6 | 6 | pull_request:
|
7 | 7 | branches: [main]
|
| 8 | + |
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: utbot_java_cli |
| 12 | + DOCKERFILE_PATH: docker/Dockerfile_java_cli |
8 | 13 |
|
9 | 14 | jobs:
|
10 | 15 | build_and_run_tests:
|
|
45 | 50 | with:
|
46 | 51 | name: utbot_intellij_tests_report
|
47 | 52 | path: utbot-intellij/build/reports/tests/test/*
|
| 53 | + |
| 54 | + - name: Set timezone |
| 55 | + uses: szenius/set-timezone@v1.0 |
| 56 | + with: |
| 57 | + timezoneLinux: "Europe/Moscow" |
| 58 | + |
| 59 | + - name: Set environment variables |
| 60 | + run: | |
| 61 | + echo "COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)"" >> $GITHUB_ENV |
| 62 | + echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV |
| 63 | + - name: Set docker tag |
| 64 | + run: |
| 65 | + echo "DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ env.COMMIT_SHORT_SHA }}"" >> $GITHUB_ENV |
| 66 | + |
| 67 | + - name: Log in to the Container registry |
| 68 | + uses: docker/login-action@v1 |
| 69 | + with: |
| 70 | + registry: ${{ env.REGISTRY }} |
| 71 | + username: ${{ github.actor }} |
| 72 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Set up Docker Buildx |
| 75 | + uses: docker/setup-buildx-action@v1 |
| 76 | + |
| 77 | + - name: Cache Docker layers |
| 78 | + uses: actions/cache@v2 |
| 79 | + with: |
| 80 | + path: /tmp/.buildx-cache |
| 81 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 82 | + restore-keys: | |
| 83 | + ${{ runner.os }}-buildx- |
| 84 | + - name: Docker meta |
| 85 | + id: meta |
| 86 | + uses: docker/metadata-action@v3 |
| 87 | + with: |
| 88 | + images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }} |
| 89 | + tags: | |
| 90 | + type=raw,value=${{ env.DOCKER_TAG }} |
| 91 | + - name: Docker Buildx (build and push) |
| 92 | + run: | |
| 93 | + docker buildx build \ |
| 94 | + -f ${{ env.DOCKERFILE_PATH }} \ |
| 95 | + --cache-from "type=local,src=/tmp/.buildx-cache" \ |
| 96 | + --cache-to "type=local,dest=/tmp/.buildx-cache-new" \ |
| 97 | + --tag ${{ steps.meta.outputs.tags }} \ |
| 98 | + --build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \ |
| 99 | + --push . |
| 100 | + # Temp fix |
| 101 | + # https://github.com/docker/build-push-action/issues/252 |
| 102 | + # https://github.com/moby/buildkit/issues/1896 |
| 103 | + - name: Move cache |
| 104 | + run: | |
| 105 | + rm -rf /tmp/.buildx-cache |
| 106 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments