---
version: 0.1

phases:

  install:
    commands:
      - echo Installing as $(whoami)
      - npm install
      - $(npm bin)/bower install --allow-root

  build:
    commands:
      - $(npm bin)/gulp build
      - $(npm bin)/gulp test
      - $(npm bin)/gulp document

  post_build:
    commands:
      # Update Api
      - aws lambda update-function-code --function-name "${REKT_CREATE_REVIEW_LAMBDA_ARN}" --zip-file "fileb://$(pwd)/dist/aws/lambda-api-gateway.zip"
      - aws apigateway put-rest-api --fail-on-warnings --mode overwrite --rest-api-id "${REKT_API_ID}" --body "file://$(pwd)/dist/site/swagger.yml"
      # TODO deploy api

      # Update Website
      - aws s3 sync dist/site "s3://${REKT_WEBSITE_BUCKET}"

artifacts:
  discard-paths: no
  files:
    - dist/**/*

---
version: 0.1

phases:

  install:
    commands:
      - echo Installing as $(whoami)
      - npm install
      - $(npm bin)/bower install --allow-root

  build:
    commands:
      - $(npm bin)/gulp build
      - $(npm bin)/gulp test
      - $(npm bin)/gulp document

  post_build:
    commands:
      # Update Api
      - aws lambda update-function-code --function-name "${REKT_CREATE_REVIEW_LAMBDA_ARN}" --zip-file "fileb://$(pwd)/dist/aws/lambda-api-gateway.zip"
      - aws lambda update-function-code --function-name "${REKT_GET_REVIEW_LAMBDA_ARN}" --zip-file "fileb://$(pwd)/dist/aws/lambda-api-gateway.zip"
      - aws apigateway put-rest-api --fail-on-warnings --mode overwrite --rest-api-id "${REKT_API_ID}" --body "file://$(pwd)/dist/site/swagger.yml"
      # TODO deploy api

      # Update Website
      - aws s3 sync dist/site "s3://${REKT_WEBSITE_BUCKET}"

artifacts:
  discard-paths: no
  files:
    - dist/**/*

Update GetReview lambda after build
Update GetReview lambda after build
