diff --git a/.github/workflows/build-utbot.yml b/.github/workflows/build-utbot.yml index 0a382ee49..f8951e307 100644 --- a/.github/workflows/build-utbot.yml +++ b/.github/workflows/build-utbot.yml @@ -5,13 +5,25 @@ on: branches: [main] jobs: + matrix-prep: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: set-matrix + uses: JoshuaTheMiller/conditional-build-matrix@0.0.1 + with: + inputFile: '.github/workflows/matrix.json' + filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]' + build: - runs-on: ubuntu-18.04 + needs: matrix-prep + strategy: + matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }} + runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }} container: - # It is impossible to parametrize image via workflow environment, - # so its name is hard-coded. - # https://github.com/actions/runner/issues/480 - image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021 + image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }} credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -20,7 +32,7 @@ jobs: UTBOT_INSTALL_DIR: /utbot_distr/install GRPC_PATH: /utbot_distr/install CLI_PATH: /utbot_distr/cli - DOCKER_TAG: 24-11-2021 + DOCKER_TAG: ${{ matrix.DOCKER_TAG }} ARTIFACT_DIR: utbot-artifact steps: - name: Checkout repository diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json new file mode 100644 index 000000000..5b33856da --- /dev/null +++ b/.github/workflows/matrix.json @@ -0,0 +1,4 @@ +{ + "DOCKER_TAG": "24-11-2021", + "OPERATING_SYSTEM_TAG": "18.04" +} \ No newline at end of file diff --git a/.github/workflows/publish-base-env.yml b/.github/workflows/publish-base-env.yml index a4675d8b0..30c88298d 100644 --- a/.github/workflows/publish-base-env.yml +++ b/.github/workflows/publish-base-env.yml @@ -5,11 +5,25 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: base_env - TAG: 24-11-2021 jobs: + matrix-prep: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: set-matrix + uses: JoshuaTheMiller/conditional-build-matrix@0.0.1 + with: + inputFile: '.github/workflows/matrix.json' + filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]' + build-docker: - runs-on: ubuntu-18.04 + needs: matrix-prep + strategy: + matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }} + runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }} permissions: contents: read packages: write @@ -31,7 +45,7 @@ jobs: uses: actions/cache@v2 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ env.TAG }} + key: ${{ runner.os }}-buildx-${{env.IMAGE_NAME}}-${{ matrix.DOCKER_TAG }} restore-keys: | ${{ runner.os }}-buildx-buildx @@ -41,7 +55,7 @@ jobs: with: images: ${{env.REGISTRY}}/${{github.repository}}/${{env.IMAGE_NAME}} tags: | - type=raw,value=${{ env.TAG }} + type=raw,value=${{ matrix.DOCKER_TAG }} - name: Build and push image uses: docker/build-push-action@v2 @@ -55,7 +69,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new build-args: | - OPERATING_SYSTEM_TAG=18.04 + OPERATING_SYSTEM_TAG=${{ matrix.OPERATING_SYSTEM_TAG }} # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 diff --git a/.github/workflows/publish-utbot.yml b/.github/workflows/publish-utbot.yml index 3240d3603..3f2303a91 100644 --- a/.github/workflows/publish-utbot.yml +++ b/.github/workflows/publish-utbot.yml @@ -5,18 +5,30 @@ on: branches: [main] jobs: + matrix-prep: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: set-matrix + uses: JoshuaTheMiller/conditional-build-matrix@0.0.1 + with: + inputFile: '.github/workflows/matrix.json' + filter: '[?runOnBranch==`${{ github.ref }}` || runOnBranch==`always`]' + publish: - runs-on: ubuntu-18.04 + needs: matrix-prep + strategy: + matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }} + runs-on: ubuntu-${{ matrix.OPERATING_SYSTEM_TAG }} env: # Environment for the job and for the container is, sadly, duplicated # https://github.com/docker/compose/issues/1837 VERSION: ${{ format('1.0.{0}', github.run_number) }} ARTIFACT_DIR: utbot-artifact container: - # It is impossible to parametrize image via workflow environment, - # so its name is hard-coded. - # https://github.com/actions/runner/issues/480 - image: ghcr.io/unittestbot/utbotcpp/base_env:24-11-2021 + image: ghcr.io/unittestbot/utbotcpp/base_env:${{ matrix.DOCKER_TAG }} credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }}