<commit_before>format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
  envs:
  - DOCKERHUB_IMG_ID_ALPHA: bitriseio/docker-bitrise-base-alpha
  - DOCKERHUB_IMG_ID_PINNED: bitriseio/docker-bitrise-base
  - DOCKER_FILE_PATH_ALPHA: ./Dockerfile
  - DOCKER_FILE_PATH_PINNED: ./Dockerfile-pinned
  - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
  - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
  - DOCKER_LOGIN_USER: $DOCKER_LOGIN_USER
  - DOCKER_LOGIN_PASS: $<PASSWORD>
  - SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
  - SLACK_CHANNEL: $SLACK_CHANNEL

  - QUAY_IMG_ID: quay.io/bitriseio/bitrise-base
  - QUAY_LOGIN_USER: $QUAY_LOGIN_USER
  - QUAY_LOGIN_PASS: $<PASSWORD>
  - IS_ALPHA: "true"
workflows:
  _alpha_envs:
    envs:
    - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
    - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
    - IS_ALPHA: "true"

  _pinned_envs:
    envs:
    - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_PINNED
    - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_PINNED
    - IS_ALPHA: "false"

  _generate_image_deploy_tag:
    steps:
    - script:
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            envman add --key 'DOCKER_IMAGE_DEPLOY_TAG' --value "v$(date +%Y_%m_%d-%H_%M)-b${BITRISE_BUILD_NUMBER}"

  _rebuild:
    after_run:
    - _run_system_report
    steps:
    - script@1.1.0:
        title: docker infos & images
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            #
            docker images
            df -kh ./
            docker info
    - script@1.1.0:
        title: docker build
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            #
            docker_build_args="--pull --no-cache"
            if [[ "${IS_CLEAN_BUILD}" == "no" ]] ; then
              docker_build_args=""
            fi
            docker build ${docker_build_args} -t "${DOCKERHUB_IMG_ID}:latest" --file "${DOCKER_FILE_PATH}" .
            docker images

  _deploy:
    before_run:
    - _generate_image_deploy_tag
    - _rebuild
    steps:
    - script@1.1.0:
        title: docker login
        inputs:
        - content: |
            #!/bin/bash
            set -e
            echo "=> Docker login..."
            docker login -u "${DOCKER_LOGIN_USER}" -p "${DOCKER_LOGIN_PASS}"
            echo "=> Quay.io login..."
            docker login -u "${QUAY_LOGIN_USER}" -p "${QUAY_LOGIN_PASS}" quay.io
    - script@1.1.0:
        title: docker push
        inputs:
        - content: |
            #!/bin/bash
            set -ex

            if [ -z "${DOCKER_IMAGE_DEPLOY_TAG}" ] ; then
              echo " [!] No DOCKER_IMAGE_DEPLOY_TAG specified!"
              exit 1
            fi

            ### Tags
            # Docker Hub
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"

            # Quay.io            
            if [[ "${IS_ALPHA}" == "true" ]]; then
              image_tag="alpha-${DOCKER_IMAGE_DEPLOY_TAG}"
              latest_image_tag="alpha"
            else
              image_tag="${DOCKER_IMAGE_DEPLOY_TAG}"
              latest_image_tag="latest"
            fi
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${image_tag}"
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${latest_image_tag}"

            ### Push
            # Docker Hub
            docker push "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"
            docker push "${DOCKERHUB_IMG_ID}:latest"

            # Quay.io
            docker push "${QUAY_IMG_ID}:${image_tag}"
            docker push "${QUAY_IMG_ID}:${latest_image_tag}"

    - slack@2.1.0:
        run_if: '{{.IsCI | and .IsBuildFailed}}'
        inputs:
        - webhook_url: $SLACK_WEBHOOK_URL
        - channel: $SLACK_CHANNEL
        - from_username: $BITRISE_APP_TITLE - OK
        - from_username_on_error: $BITRISE_APP_TITLE - ERROR
        - message: |
            Finished:

            - Branch: *$BITRISE_GIT_BRANCH*
            - Tag: $BITRISE_GIT_TAG
            - Image ID: $DOCKERHUB_IMG_ID
            - Image tag: $DOCKER_IMAGE_DEPLOY_TAG
            - Build URL: $BITRISE_BUILD_URL
            - Build Number: $BITRISE_BUILD_NUMBER
            - Build Message: $BITRISE_GIT_MESSAGE

  _run_system_report:
    steps:
    - script@1.1.0:
        title: run platform_report.sh
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            #
            docker run --rm \
              -v "$(pwd):/bitrise/src" \
              -v "/var/run/docker.sock:/var/run/docker.sock" \
              -v "$(which bitrise-bridge):/usr/local/bin/bitrise-bridge" \
              -e CI="$CI" \
              "${DOCKERHUB_IMG_ID}:latest" bash /bitrise/src/system_report.sh

  deploy-alpha:
    before_run:
    - _alpha_envs
    after_run:
    - _deploy
  deploy-pinned:
    before_run:
    - _pinned_envs
    after_run:
    - _deploy
  rebuild-alpha:
    before_run:
    - _alpha_envs
    after_run:
    - _rebuild
  rebuild-pinned:
    before_run:
    - _pinned_envs
    after_run:
    - _rebuild
  run_system_report_on_alpha:
    before_run:
    - _alpha_envs
    after_run:
    - _run_system_report
  simple-build-alpha:
    before_run:
    - _alpha_envs
    envs:
    - IS_CLEAN_BUILD: "no"
    after_run:
    - _rebuild
<commit_msg>[IN-2902] Remove unused step with deprecated tools (#411)<commit_after>format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
  envs:
  - DOCKERHUB_IMG_ID_ALPHA: bitriseio/docker-bitrise-base-alpha
  - DOCKERHUB_IMG_ID_PINNED: bitriseio/docker-bitrise-base
  - DOCKER_FILE_PATH_ALPHA: ./Dockerfile
  - DOCKER_FILE_PATH_PINNED: ./Dockerfile-pinned
  - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
  - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
  - DOCKER_LOGIN_USER: $DOCKER_LOGIN_USER
  - DOCKER_LOGIN_PASS: $DOCKER_LOGIN_PASS
  - SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
  - SLACK_CHANNEL: $SLACK_CHANNEL

  - QUAY_IMG_ID: quay.io/bitriseio/bitrise-base
  - QUAY_LOGIN_USER: $QUAY_LOGIN_USER
  - QUAY_LOGIN_PASS: $QUAY_LOGIN_PASS
  - IS_ALPHA: "true"
workflows:
  _alpha_envs:
    envs:
    - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
    - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
    - IS_ALPHA: "true"

  _pinned_envs:
    envs:
    - DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_PINNED
    - DOCKER_FILE_PATH: $DOCKER_FILE_PATH_PINNED
    - IS_ALPHA: "false"

  _generate_image_deploy_tag:
    steps:
    - script:
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            envman add --key 'DOCKER_IMAGE_DEPLOY_TAG' --value "v$(date +%Y_%m_%d-%H_%M)-b${BITRISE_BUILD_NUMBER}"

  _rebuild:
    steps:
    - script@1.1.0:
        title: docker infos & images
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            #
            docker images
            df -kh ./
            docker info
    - script@1.1.0:
        title: docker build
        inputs:
        - content: |
            #!/bin/bash
            set -ex
            #
            docker_build_args="--pull --no-cache"
            if [[ "${IS_CLEAN_BUILD}" == "no" ]] ; then
              docker_build_args=""
            fi
            docker build ${docker_build_args} -t "${DOCKERHUB_IMG_ID}:latest" --file "${DOCKER_FILE_PATH}" .
            docker images

  _deploy:
    before_run:
    - _generate_image_deploy_tag
    - _rebuild
    steps:
    - script@1.1.0:
        title: docker login
        inputs:
        - content: |
            #!/bin/bash
            set -e
            echo "=> Docker login..."
            docker login -u "${DOCKER_LOGIN_USER}" -p "${DOCKER_LOGIN_PASS}"
            echo "=> Quay.io login..."
            docker login -u "${QUAY_LOGIN_USER}" -p "${QUAY_LOGIN_PASS}" quay.io
    - script@1.1.0:
        title: docker push
        inputs:
        - content: |
            #!/bin/bash
            set -ex

            if [ -z "${DOCKER_IMAGE_DEPLOY_TAG}" ] ; then
              echo " [!] No DOCKER_IMAGE_DEPLOY_TAG specified!"
              exit 1
            fi

            ### Tags
            # Docker Hub
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"

            # Quay.io            
            if [[ "${IS_ALPHA}" == "true" ]]; then
              image_tag="alpha-${DOCKER_IMAGE_DEPLOY_TAG}"
              latest_image_tag="alpha"
            else
              image_tag="${DOCKER_IMAGE_DEPLOY_TAG}"
              latest_image_tag="latest"
            fi
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${image_tag}"
            docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${latest_image_tag}"

            ### Push
            # Docker Hub
            docker push "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"
            docker push "${DOCKERHUB_IMG_ID}:latest"

            # Quay.io
            docker push "${QUAY_IMG_ID}:${image_tag}"
            docker push "${QUAY_IMG_ID}:${latest_image_tag}"

    - slack@2.1.0:
        run_if: '{{.IsCI | and .IsBuildFailed}}'
        inputs:
        - webhook_url: $SLACK_WEBHOOK_URL
        - channel: $SLACK_CHANNEL
        - from_username: $BITRISE_APP_TITLE - OK
        - from_username_on_error: $BITRISE_APP_TITLE - ERROR
        - message: |
            Finished:

            - Branch: *$BITRISE_GIT_BRANCH*
            - Tag: $BITRISE_GIT_TAG
            - Image ID: $DOCKERHUB_IMG_ID
            - Image tag: $DOCKER_IMAGE_DEPLOY_TAG
            - Build URL: $BITRISE_BUILD_URL
            - Build Number: $BITRISE_BUILD_NUMBER
            - Build Message: $BITRISE_GIT_MESSAGE

  deploy-alpha:
    before_run:
    - _alpha_envs
    after_run:
    - _deploy
  deploy-pinned:
    before_run:
    - _pinned_envs
    after_run:
    - _deploy
  rebuild-alpha:
    before_run:
    - _alpha_envs
    after_run:
    - _rebuild
  rebuild-pinned:
    before_run:
    - _pinned_envs
    after_run:
    - _rebuild
  simple-build-alpha:
    before_run:
    - _alpha_envs
    envs:
    - IS_CLEAN_BUILD: "no"
    after_run:
    - _rebuild

{'fraction_non_alphanumeric': 0.11122047244094488, 'fraction_numerical': 0.004724409448818898, 'mean_word_length': 1.8711500423848544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1138618', 'n_tokens_mistral': 3893, 'n_tokens_neox': 3726, 'n_words': 580}