Skip to content

Commit cbd0df6

Browse files
committed
tagging ecs
1 parent 53e4fb5 commit cbd0df6

File tree

1 file changed

+15
-26
lines changed
  • ansible/roles/deploy-ecs-proxies/tasks

1 file changed

+15
-26
lines changed

ansible/roles/deploy-ecs-proxies/tasks/main.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,40 +82,29 @@
8282
register: tfapply
8383
when: not do_not_terraform
8484

85-
- name: "{{ item.env }} | Login and pull image"
85+
- name: Retag and promote ECS image (release pipelines only)
86+
when: pr_number is not defined or pr_number == ""
8687
vars:
87-
REG: "{{ item.account }}.dkr.ecr.eu-west-2.amazonaws.com"
88+
PTL_REG: "{{ PTL_ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com"
89+
PROD_REG: "{{ PROD_ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com"
8890
IMG: "{{ service_id }}_{{ ecs_service[0].name }}"
8991
TAG: "{{ build_label }}"
92+
NEW: "ecs-{{ build_label }}"
9093
shell: |
9194
aws ecr get-login-password --region eu-west-2 \
92-
| docker login --username AWS --password-stdin {{ REG }}
95+
| docker login --username AWS --password-stdin {{ PTL_REG }}
9396
94-
docker pull {{ REG }}/{{ IMG }}:{{ TAG }}
95-
args:
96-
executable: /bin/bash
97-
loop:
98-
- { env: "PTL", account: "{{ PTL_ACCOUNT_ID }}" }
99-
- { env: "PROD", account: "{{ PROD_ACCOUNT_ID }}" }
100-
loop_control:
101-
label: "{{ item.env }}"
102-
103-
- name: "{{ item.env }} | Retag and push image"
104-
vars:
105-
REG: "{{ item.account }}.dkr.ecr.eu-west-2.amazonaws.com"
106-
IMG: "{{ service_id }}_{{ ecs_service[0].name }}"
107-
TAG: "{{ build_label }}"
108-
NEW: "ecs-{{ build_label }}"
109-
shell: |
110-
docker tag {{ REG }}/{{ IMG }}:{{ TAG }} {{ REG }}/{{ IMG }}:{{ NEW }}
111-
docker push {{ REG }}/{{ IMG }}:{{ NEW }}
97+
docker pull {{ PTL_REG }}/{{ IMG }}:{{ TAG }}
98+
docker tag {{ PTL_REG }}/{{ IMG }}:{{ TAG }} {{ PTL_REG }}/{{ IMG }}:{{ NEW }}
99+
docker push {{ PTL_REG }}/{{ IMG }}:{{ NEW }}
100+
101+
aws ecr get-login-password --region eu-west-2 \
102+
| docker login --username AWS --password-stdin {{ PROD_REG }}
103+
104+
docker tag {{ PTL_REG }}/{{ IMG }}:{{ NEW }} {{ PROD_REG }}/{{ IMG }}:{{ NEW }}
105+
docker push {{ PROD_REG }}/{{ IMG }}:{{ NEW }}
112106
args:
113107
executable: /bin/bash
114-
loop:
115-
- { env: "PTL", account: "{{ PTL_ACCOUNT_ID }}" }
116-
- { env: "PROD", account: "{{ PROD_ACCOUNT_ID }}" }
117-
loop_control:
118-
label: "{{ item.env }}"
119108

120109
rescue:
121110
- name: output plan

0 commit comments

Comments
 (0)