-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
83 lines (71 loc) · 1.91 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
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
image: docker:19.03.5
services:
- docker:19.03.5-dind
stages:
- Build
- Push
- Deploy
before_script:
- apk add python3
- pip3 install awscli==1.18.8
- docker load --input data/image.tar
- $(aws ecr get-login --no-include-email --region us-east-1)
Build Staging:
stage: Build
before_script: []
script:
- echo Building...
- mkdir data/
- docker build --compress -t weather-app --build-arg="CONFIG=staging" .
- docker save --output data/image.tar weather-app
artifacts:
name: image
paths:
- data/
rules:
- if: "$CI_COMMIT_BRANCH == 'main'"
Build Production:
stage: Build
before_script: []
script:
- echo Building...
- mkdir data/
- docker build --compress -t weather-app --build-arg="CONFIG=production" .
- docker save --output data/image.tar weather-app
artifacts:
name: image
paths:
- data/
rules:
- if: "$CI_COMMIT_BRANCH == 'production'"
Push Staging:
stage: Push
script:
- echo Pushing to Staging Environment...
- docker tag weather-app $ECR_REPO:staging
- docker push $ECR_REPO:staging
rules:
- if: "$CI_COMMIT_BRANCH == 'main'"
Push Production:
stage: Push
script:
- echo Pushing to Production Environment...
- docker tag weather-app $ECR_REPO:production
- docker push $ECR_REPO:production
rules:
- if: "$CI_COMMIT_BRANCH == 'production'"
Deploy Staging:
stage: Deploy
script:
- echo Queueing new ECS service...
- aws ecs update-service --cluster wwa-staging-cluster --service wwa-staging-server --force-new-deployment --region us-east-1
rules:
- if: "$CI_COMMIT_BRANCH == 'main'"
Deploy Production:
stage: Deploy
script:
- echo Queueing new ECS service...
- aws ecs update-service --cluster wwa-production-cluster --service wwa-production-server --force-new-deployment --region us-east-1
rules:
- if: "$CI_COMMIT_BRANCH == 'production'"
when: manual