version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 16
  pre_build:
    commands:
      - npm install 
  build:
    commands:
      - pwd
      - ls -al
      - npm run build
      - ls -al
      - cd .next && ll
  post_build:
    commands:
      - |
        echo "BRANCH_NAME: $BRANCH_NAME"
        if [ "$BRANCH_NAME" = "staging" ]; then
          aws s3 sync dist/ s3://uat.wesellrestaurants.com
        elif [ "$BRANCH_NAME" = "university" ]; then
          aws s3 sync dist/ s3://university.wesellrestaurants.com
        elif [ "$BRANCH_NAME" = "development" ]; then
          aws s3 sync dist/ s3://wesellrestaurants.com
        else
          echo "No S3 bucket specified for this branch."
          exit 1
        fi

artifacts:
  files: '**/*'
  base-directory: dist
  discard-paths: yes
