summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
blob: 332c58c869518cd786a351a15f5810c26911f9bb (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# WARNING (post-GitLab 13.0):
#
# This CI template should NOT be included in your own CI configuration files:
# 'review_ecs' and 'production_ecs' are two temporary names given to the jobs below.
#
# Should this template be included in your CI configuration, the upcoming name changes could
# then result in potentially breaking your future pipelines.
#
# More about including CI templates: https://docs.gitlab.com/ee/ci/yaml/#includetemplate

.ecs_image:
  image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest'

.deploy_to_ecs:
  extends: .ecs_image
  dependencies: []
  script:
    - ecs update-task-definition

.review_ecs_base:
  stage: review
  extends: .deploy_to_ecs

.production_ecs_base:
  stage: production
  extends: .deploy_to_ecs
  environment:
    name: production

.stop_review_ecs_base:
  extends: .ecs_image
  stage: cleanup
  allow_failure: true
  script:
    - ecs stop-task

review_ecs:
  extends: .review_ecs_base
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: stop_review_ecs
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'

stop_review_ecs:
  extends: .stop_review_ecs_base
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
      when: manual

review_fargate:
  extends: .review_ecs_base
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: stop_review_fargate
  script:
    - ecs update-task-definition
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'

stop_review_fargate:
  extends: .stop_review_ecs_base
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
      when: manual

production_ecs:
  extends: .production_ecs_base
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'

production_fargate:
  extends: .production_ecs_base
  rules:
    - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
      when: never
    - if: '$CI_KUBERNETES_ACTIVE'
      when: never
    - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'