<commit_before>version: 2
jobs:
  generate_dockerfiles:
    working_directory: ~/repo
    docker:
      - image: gcc:7
    steps:
      - checkout
      - run:
          name: Generate Dockerfiles
          command: make -j
      - run:
          name: Prepare Artifacts
          command: |
            mkdir /tmp/dockerfiles
            find . -name Dockerfile -type f | grep -v shared | xargs -I{} cp -v --parents {} /tmp/dockerfiles
      - store_artifacts:
          path: /tmp/dockerfiles
          destination: Dockerfiles
      # upload Dockerfiles to circleci-public/circleci-dockerfiles repo
      - add_ssh_keys:
          fingerprints:
            - "af:0a:93:75:51:75:1f:16:90:d9:97:b1:7a:bb:f0:27"
      - run:
          name: git config
          command: |
            git config --global user.email "$<EMAIL>"
            git config --global user.name "$CIRCLE_USERNAME"
      - run: git clone <EMAIL>:CircleCI-Public/circleci-dockerfiles.git
      # only push Dockerfiles to github on circleci-images pushes to "master" or "production"
      - run:
          name: branch control flow & git push
          working_directory: circleci-dockerfiles
          command: |
            if [[ "$CIRCLE_BRANCH" == "production" ]]
            then
              export DOCKERFILES_BRANCH=master
            fi
            if [[ "$CIRCLE_BRANCH" == "master" ]]
            then
              export DOCKERFILES_BRANCH=staging
            fi
            if [ ! -e $DOCKERFILES_BRANCH ]
            then
              git checkout $DOCKERFILES_BRANCH
              cp -rfv /tmp/dockerfiles/* ~/repo/circleci-dockerfiles
              git add .
              git commit --allow-empty -m "Dockerfiles from $CIRCLE_BUILD_URL"
              git push -f origin $DOCKERFILES_BRANCH
            fi

  refresh_tools_cache:
    docker:
    - image: circleci/python:latest
    steps:
    - checkout
    - run: sudo pip install awscli
    - run: cd ./shared/images; ./refresh-tools-cache

  publish_image: &publish_image
    machine: true
    working_directory: ~/circleci-bundles
    steps:
      - checkout
      - run:
          name: Docker Login
          command: docker login -u $DOCKER_USER -p $DOCKER_PASS
      - run:
          name: Build and Publish Images
          command: |
            export COMPUTED_ORG=notnoopci
            if [[ "$CIRCLE_BRANCH" == "production" ]]
            then
              export COMPUTED_ORG=circleci
            fi
            export NEW_ORG=${NEW_ORG:-$COMPUTED_ORG}

            make -j $PLATFORM/publish_images
      - store_artifacts:
          path: "."
          destination: circleci-bundles

  publish_android:
    <<: *publish_image
    environment:
      - PLATFORM: android

  publish_node:
    <<: *publish_image<commit_msg>push staging images to new org<commit_after>version: 2
jobs:
  generate_dockerfiles:
    working_directory: ~/repo
    docker:
      - image: gcc:7
    steps:
      - checkout
      - run:
          name: Generate Dockerfiles
          command: make -j
      - run:
          name: Prepare Artifacts
          command: |
            mkdir /tmp/dockerfiles
            find . -name Dockerfile -type f | grep -v shared | xargs -I{} cp -v --parents {} /tmp/dockerfiles
      - store_artifacts:
          path: /tmp/dockerfiles
          destination: Dockerfiles
      # upload Dockerfiles to circleci-public/circleci-dockerfiles repo
      - add_ssh_keys:
          fingerprints:
            - "af:0a:93:75:51:75:1f:16:90:d9:97:b1:7a:bb:f0:27"
      - run:
          name: git config
          command: |
            git config --global user.email "$<EMAIL>"
            git config --global user.name "$CIRCLE_USERNAME"
      - run: git clone <EMAIL>:CircleCI-Public/circleci-dockerfiles.git
      # only push Dockerfiles to github on circleci-images pushes to "master" or "production"
      - run:
          name: branch control flow & git push
          working_directory: circleci-dockerfiles
          command: |
            if [[ "$CIRCLE_BRANCH" == "production" ]]
            then
              export DOCKERFILES_BRANCH=master
            fi
            if [[ "$CIRCLE_BRANCH" == "master" ]]
            then
              export DOCKERFILES_BRANCH=staging
            fi
            if [ ! -e $DOCKERFILES_BRANCH ]
            then
              git checkout $DOCKERFILES_BRANCH
              cp -rfv /tmp/dockerfiles/* ~/repo/circleci-dockerfiles
              git add .
              git commit --allow-empty -m "Dockerfiles from $CIRCLE_BUILD_URL"
              git push -f origin $DOCKERFILES_BRANCH
            fi

  refresh_tools_cache:
    docker:
    - image: circleci/python:latest
    steps:
    - checkout
    - run: sudo pip install awscli
    - run: cd ./shared/images; ./refresh-tools-cache

  publish_image: &publish_image
    machine: true
    working_directory: ~/circleci-bundles
    steps:
      - checkout
      - run:
          name: Docker Login
          command: docker login -u $DOCKER_USER -p $DOCKER_PASS
      - run:
          name: Build and Publish Images
          command: |
            export COMPUTED_ORG=ccistaging
            if [[ "$CIRCLE_BRANCH" == "production" ]]
            then
              export COMPUTED_ORG=circleci
            fi
            export NEW_ORG=${NEW_ORG:-$COMPUTED_ORG}

            make -j $PLATFORM/publish_images
      - store_artifacts:
          path: "."
          destination: circleci-bundles

  publish_android:
    <<: *publish_image
    environment:
      - PLATFORM: android

  publish_node:
    <<: *publish_image
{'fraction_non_alphanumeric': 0.09012567324955116, 'fraction_numerical': 0.008617594254937163, 'mean_word_length': 1.7017458777885548, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1314790', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1649, 'n_words': 402}