-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
46 lines (40 loc) · 1.31 KB
/
.gitlab-ci.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
stages:
- build
- run
variables:
AWS_REGION: us-east-1
APP_NAME: k8sdocker
ENV_NAME: K8sdocker-env
FILE: $CI_COMMIT_REF_NAME-$CI_PIPELINE_ID
BUCKET: "elasticbeanstalk-us-east-1-894244321548"
AWS_PLATFORM: Docker
create_eb_version:
stage: build
image: python:latest
allow_failure: false
script: |
pip install awscli #Install awscli tools
echo "Creating zip file"
python zip.py ${APP_NAME}
echo "Creating AWS Version Label"
AWS_VERSION_LABEL=${APP_NAME}-${APP_VERSION}-${CI_PIPELINE_ID}
S3_KEY="$AWS_VERSION_LABEL.zip"
echo "Uploading to S3"
aws s3 cp ${APP_NAME}.zip s3://${S3_BUCKET}/${S3_KEY} --region ${AWS_REGION}
echo "Creating new app version"
aws elasticbeanstalk create-application-version \
--application-name ${APP_NAME} \
--version-label $AWS_VERSION_LABEL \
--region ${AWS_REGION} \
--source-bundle S3Bucket=${S3_BUCKET},S3Key=${S3_KEY} \
--description "${CI_COMMIT_DESCRIPTION}" \
--auto-create-application \
deploy_aws_eb:
stage: run
image: coxauto/aws-ebcli
when: manual
script: |
AWS_VERSION_LABEL=${APP_NAME}-${APP_VERSION}-${CI_PIPELINE_ID}
echo "Deploying app"
eb init -i ${APP_NAME} -p ${AWS_PLATFORM} -k ${AWS_ID} --region ${AWS_REGION}
eb deploy ${APP_NAME} --version ${AWS_VERSION_LABEL}