-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci-deploy.yml
95 lines (91 loc) · 6.42 KB
/
.gitlab-ci-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.deploy:
image: python:3.9
cache:
paths: []
before_script:
- pip install awscli
- apt-get update -y
- apt-get install -y zip htpdate
- htpdate -a google.com
- mkdir ~/.aws/
- touch ~/.aws/credentials
deploy:staging:
extends: .deploy
stage: deploy
environment:
name: staging
dependencies:
- build:staging
when: manual
only:
refs:
- staging
- looker-sso
- contact-us
script:
- printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\nregion = %s\n" "$AWS_TEST_ACCESS_KEY_ID" "$AWS_TEST_SECRET_ACCESS_KEY" "$AWS_TEST_REGION" >> ~/.aws/credentials
- export VERSION_LABEL="${CI_COMMIT_SHA}-${AWS_TEST_EB_APP_ENVIRONMENT_NAME_STAGING}-$(date +%s)"
# Deploy web
- bash aws/web/build.sh
- cd build_web && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
- aws s3 cp "build_web/${CI_COMMIT_SHA}.zip" "s3://${AWS_TEST_EB_BUCKET_NAME}/${AWS_TEST_EB_APP_NAME}/${AWS_TEST_EB_APP_ENVIRONMENT_NAME_STAGING}/${CI_COMMIT_SHA}.zip"
- aws elasticbeanstalk create-application-version --application-name "${AWS_TEST_EB_APP_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_TEST_EB_BUCKET_NAME}",S3Key="${AWS_TEST_EB_APP_NAME}/${AWS_TEST_EB_APP_ENVIRONMENT_NAME_STAGING}/${CI_COMMIT_SHA}.zip" --region "${AWS_TEST_REGION}"
- aws elasticbeanstalk update-environment --environment-name "${AWS_TEST_EB_APP_ENVIRONMENT_NAME_STAGING}" --application-name "${AWS_TEST_EB_APP_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_TEST_REGION}"
# # Deploy worker
# - bash aws/worker/build.sh
# - cd build_worker && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
# - aws s3 cp "build_worker/${CI_COMMIT_SHA}.zip" "s3://${AWS_TEST_EB_BUCKET_NAME}/${AWS_TEST_EB_QUEUE_NAME}/${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_STAGING}/${CI_COMMIT_SHA}.zip"
# - aws elasticbeanstalk create-application-version --application-name "${AWS_TEST_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_TEST_EB_BUCKET_NAME}",S3Key="${AWS_TEST_EB_QUEUE_NAME}/${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_STAGING}/${CI_COMMIT_SHA}.zip" --region "${AWS_TEST_REGION}"
# - aws elasticbeanstalk update-environment --environment-name "${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_STAGING}" --application-name "${AWS_TEST_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_TEST_REGION}"
deploy:prod:
extends: .deploy
stage: deploy
environment:
name: prod
dependencies:
- build:prod
when: manual
only:
refs:
- prod
script:
- printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\nregion = %s\n" "$AWS_PROD_ACCESS_KEY_ID" "$AWS_PROD_SECRET_ACCESS_KEY" "$AWS_PROD_REGION" >> ~/.aws/credentials
- export VERSION_LABEL="${CI_COMMIT_SHA}-${AWS_PROD_EB_APP_ENVIRONMENT_NAME}-$(date +%s)"
# Deploy web
- bash aws/web/build.sh
- cd build_web && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
- aws s3 cp "build_web/${CI_COMMIT_SHA}.zip" "s3://${AWS_PROD_EB_BUCKET_NAME}/${AWS_PROD_EB_APP_NAME}/${AWS_PROD_EB_APP_ENVIRONMENT_NAME}/${CI_COMMIT_SHA}.zip"
- aws elasticbeanstalk create-application-version --application-name "${AWS_PROD_EB_APP_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_PROD_EB_BUCKET_NAME}",S3Key="${AWS_PROD_EB_APP_NAME}/${AWS_PROD_EB_APP_ENVIRONMENT_NAME}/${CI_COMMIT_SHA}.zip" --region "${AWS_PROD_REGION}"
- aws elasticbeanstalk update-environment --environment-name "${AWS_PROD_EB_APP_ENVIRONMENT_NAME}" --application-name "${AWS_PROD_EB_APP_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_PROD_REGION}"
# # Deploy worker
# - bash aws/worker/build.sh
# - cd build_worker && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
# - aws s3 cp "build_worker/${CI_COMMIT_SHA}.zip" "s3://${AWS_PROD_EB_BUCKET_NAME}/${AWS_PROD_EB_QUEUE_NAME}/${AWS_PROD_EB_QUEUE_ENVIRONMENT_NAME}/${CI_COMMIT_SHA}.zip"
# - aws elasticbeanstalk create-application-version --application-name "${AWS_PROD_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_PROD_EB_BUCKET_NAME}",S3Key="${AWS_PROD_EB_QUEUE_NAME}/${AWS_PROD_EB_QUEUE_ENVIRONMENT_NAME}/${CI_COMMIT_SHA}.zip" --region "${AWS_PROD_REGION}"
# - aws elasticbeanstalk update-environment --environment-name "${AWS_PROD_EB_QUEUE_ENVIRONMENT_NAME}" --application-name "${AWS_PROD_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_PROD_REGION}"
deploy:qa:
extends: .deploy
stage: deploy
environment:
name: qa
dependencies:
- build:qa
only:
refs:
- qa
script:
- printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\nregion = %s\n" "$AWS_TEST_ACCESS_KEY_ID" "$AWS_TEST_SECRET_ACCESS_KEY" "$AWS_TEST_REGION" >> ~/.aws/credentials
- export VERSION_LABEL="${CI_COMMIT_SHA}-${AWS_TEST_EB_APP_ENVIRONMENT_NAME_QA}-$(date +%s)"
# Deploy web
- ls -la
- bash aws/web/build.sh
- cd build_web && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
- aws s3 cp "build_web/${CI_COMMIT_SHA}.zip" "s3://${AWS_TEST_EB_BUCKET_NAME}/${AWS_TEST_EB_APP_NAME}/${AWS_TEST_EB_APP_ENVIRONMENT_NAME_QA}/${CI_COMMIT_SHA}.zip"
- aws elasticbeanstalk create-application-version --application-name "${AWS_TEST_EB_APP_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_TEST_EB_BUCKET_NAME}",S3Key="${AWS_TEST_EB_APP_NAME}/${AWS_TEST_EB_APP_ENVIRONMENT_NAME_QA}/${CI_COMMIT_SHA}.zip" --region "${AWS_TEST_REGION}"
- aws elasticbeanstalk update-environment --environment-name "${AWS_TEST_EB_APP_ENVIRONMENT_NAME_QA}" --application-name "${AWS_TEST_EB_APP_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_TEST_REGION}"
# # Deploy worker
# - bash aws/worker/build.sh
# - cd build_worker && zip -qq -r "${CI_COMMIT_SHA}.zip" . ??* && cd ..
# - aws s3 cp "build_worker/${CI_COMMIT_SHA}.zip" "s3://${AWS_TEST_EB_BUCKET_NAME}/${AWS_TEST_EB_QUEUE_NAME}/${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_QA}/${CI_COMMIT_SHA}.zip"
# - aws elasticbeanstalk create-application-version --application-name "${AWS_TEST_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --source-bundle S3Bucket="${AWS_TEST_EB_BUCKET_NAME}",S3Key="${AWS_TEST_EB_QUEUE_NAME}/${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_QA}/${CI_COMMIT_SHA}.zip" --region "${AWS_TEST_REGION}"
# - aws elasticbeanstalk update-environment --environment-name "${AWS_TEST_EB_QUEUE_ENVIRONMENT_NAME_QA}" --application-name "${AWS_TEST_EB_QUEUE_NAME}" --version-label "$VERSION_LABEL" --region "${AWS_TEST_REGION}"