Guest User

Untitled

a guest
May 19th, 2019
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. version: 2.1
  2. orbs:
  3. aws-cli: circleci/aws-cli@0.1.11
  4. aws-ecr: circleci/aws-ecr@0.0.4
  5. aws-ecs: circleci/aws-ecs@0.0.6
  6. jobs:
  7. build-job:
  8. working_directory: ~/app
  9. docker:
  10. - image: 'circleci/node:10.15.1'
  11. steps:
  12. - checkout
  13. # Download and cache dependencies
  14. - restore_cache:
  15. keys:
  16. - v2-dep-{{ .Branch }}-{{ checksum "package.json" }}
  17. # fallback to using the latest cache if no exact match is found
  18. - v2-dep-
  19.  
  20. - run: make install
  21. - run: make build
  22. - run: make test
  23. - save_cache:
  24. paths:
  25. - node_modules
  26. key: v2-dep-{{ .Branch }}-{{ checksum "package.json" }}
  27. - save_cache:
  28. paths:
  29. - dist
  30. key: v2-dep-{{ .Branch }}-{{ checksum "package.json" }}-{{ .Revision }}
  31.  
  32. # Deploy to s3 (currently not using)
  33. deploy-s3-job:
  34. docker:
  35. - image: 'circleci/node:10.15.1'
  36. - image: 'circleci/python:3.7'
  37. working_directory: ~/app
  38. steps:
  39. - checkout
  40. # Download and cache dependencies
  41. - run:
  42. name: Install Dependencies
  43. command: |`
  44. printf "[default]\naccess_key = $AWS_ACCESS_KEY_ID\nsecret_key = $AWS_SECRET_ACCESS_KEY" >> ~/.s3cfg
  45. mkdir ~/.aws
  46. printf "[default]\naws_access_key_id = $AWS_ACCESS_KEY_ID\naws_secret_access_key = $AWS_SECRET_ACCESS_KEY" >> ~/.aws/credentials
  47. sudo apt-get update
  48. sudo apt install s3cmd -y
  49. - restore_cache:
  50. keys:
  51. - v2-dep-{{ .Branch }}-{{ checksum "package.json" }}-{{ .Revision }}
  52. - run:
  53. name: Deploy
  54. command: |
  55. make s3upload
  56. verify-deployment:
  57. docker:
  58. - image: 'circleci/python:3.7.1'
  59. steps:
  60. - aws-cli/install
  61. - aws-cli/configure
  62. - run:
  63. name: Get last task definition
  64. command: >
  65. TASK_DEFINITION_ARN=$(aws ecs describe-task-definition \
  66. --task-definition ${APP_PREFIX}-service \
  67. --output text \
  68. --query 'taskDefinition.taskDefinitionArn')
  69. echo "export TASK_DEFINITION_ARN='${TASK_DEFINITION_ARN}'" >>
  70. $BASH_ENV
  71. - aws-ecs/verify-revision-is-deployed:
  72. family: '${APP_PREFIX}-service'
  73. cluster-name: '${APP_PREFIX}'
  74. task-definition-arn: '${TASK_DEFINITION_ARN}'
  75.  
  76.  
  77. workflows:
  78. version: 2.1
  79. build-deploy:
  80. jobs:
  81. - build-job
  82. - aws-ecr/build_and_push_image:
  83. requires:
  84. - build-job
  85. account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com'
  86. repo: '${APP_PREFIX}'
  87. region: '${AWS_REGION}'
  88. tag: '${CIRCLE_SHA1}'
  89. filters:
  90. branches:
  91. only: deployments
  92. - aws-ecs/deploy-service-update:
  93. requires:
  94. - aws-ecr/build_and_push_image
  95. family: '${APP_PREFIX}-service'
  96. cluster-name: '${APP_PREFIX}'
  97. container-image-name-updates: 'container=${APP_PREFIX},tag=${CIRCLE_SHA1}'
  98. filters:
  99. branches:
  100. only: deployments
  101. - verify-deployment:
  102. requires:
  103. - aws-ecs/deploy-service-update
  104. filters:
  105. branches:
  106. only: deployments
RAW Paste Data