#  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#  SPDX-License-Identifier: MIT-0
version: 0.2
env:
  git-credential-helper: yes
phases:
  install:
    commands:
      - echo "in the install phase"
      - apt-get update && apt-get -y install jq python3-pip python3-dev && pip3 install --upgrade awscli
    finally:
      - echo This always runs even if the login command fails 
  pre_build:
    commands:
      - echo "Setting CodeCommit Credentials"
  build:
    commands:
      - echo "Build started on $(date)"
      - git clone https://github.com/awslabs/git-secrets
      - cd git-secrets
      - make install
      - cd $CODEBUILD_SRC_DIR
      - git clone https://git-codecommit.us-gov-west-1.amazonaws.com/v1/repos/$CODECOMMIT_REPO_NAME
      - cd $CODECOMMIT_REPO_NAME && ls -lrt
      - git secrets --install
      - git secrets --register-aws
      ## Adding additional patterns, for example password
      #- git secrets --add password\s*=\s*.+
      - git secrets --scan --recursive
  post_build:
    commands:
      - echo "Build completed on $(date)"
artifacts:
  type: zip
  files: '**/*'