-
Notifications
You must be signed in to change notification settings - Fork 3
112 lines (111 loc) · 4.52 KB
/
deploy-managed-ema-image.yaml
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
name: Deploy Managed EMA
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "The tag of the image to push. We'll pull the main image and re-tag it with this."
required: true
default: "A.B.C"
deployEnvironment:
description: "Environment to deploy to (development/staging/production)."
required: true
type: choice
options:
- development
- staging
- production
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]
- name: ECR (Dev) - Pull Image
run: |
ECR_DEV_IMAGE="${{ steps.login-ecr.outputs.registry }}/${{ github.event.repository.name }}:main"
docker pull $ECR_DEV_IMAGE
echo "ECR_DEV_IMAGE=$ECR_DEV_IMAGE" >> $GITHUB_ENV
- name: GCR (Dev) - Login
if: ${{ github.event.inputs.deployEnvironment == 'development' }}
uses: docker/login-action@v3
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.DEV_GCP_SERVICE_ACCOUNT }}
- name: GCR (Dev) - Tag and Push
if: ${{ github.event.inputs.deployEnvironment == 'development' }}
run: |
GCR_IMAGE_TAGS_TO_PUSH=(
"${{ github.event.inputs.releaseVersion }}"
)
GCR_DEV_IMAGE_REPO="gcr.io/${{ secrets.DEV_GCP_PROJECT_ID }}/${{ github.event.repository.name }}"
for current_tag in ${GCR_IMAGE_TAGS_TO_PUSH[@]}
do
docker tag $ECR_DEV_IMAGE $GCR_DEV_IMAGE_REPO:$current_tag
docker push $GCR_DEV_IMAGE_REPO:$current_tag
done
- name: GCR (Staging) - Login
if: ${{ github.event.inputs.deployEnvironment == 'staging' }}
uses: docker/login-action@v3
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.STAGING_GCP_SERVICE_ACCOUNT }}
- name: GCR (Staging) - Tag and Push
if: ${{ github.event.inputs.deployEnvironment == 'staging' }}
run: |
GCR_IMAGE_TAGS_TO_PUSH=(
"${{ github.event.inputs.releaseVersion }}"
)
GCR_STAGING_IMAGE_REPO="gcr.io/${{ secrets.STAGING_GCP_PROJECT_ID }}/${{ github.event.repository.name }}"
for current_tag in ${GCR_IMAGE_TAGS_TO_PUSH[@]}
do
docker tag $ECR_DEV_IMAGE $GCR_STAGING_IMAGE_REPO:$current_tag
docker push $GCR_STAGING_IMAGE_REPO:$current_tag
done
- name: GCR (Production) - Login
if: ${{ github.event.inputs.deployEnvironment == 'production' }}
uses: docker/login-action@v3
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.PROD_GCP_SERVICE_ACCOUNT }}
- name: GCR (Prod) - Tag and Push
if: ${{ github.event.inputs.deployEnvironment == 'production' }}
run: |
GCR_IMAGE_TAGS_TO_PUSH=(
"${{ github.event.inputs.releaseVersion }}"
)
GCR_PROD_IMAGE_REPO="gcr.io/${{ secrets.PROD_GCP_PROJECT_ID }}/${{ github.event.repository.name }}"
for current_tag in ${GCR_IMAGE_TAGS_TO_PUSH[@]}
do
docker tag $ECR_DEV_IMAGE $GCR_PROD_IMAGE_REPO:$current_tag
docker push $GCR_PROD_IMAGE_REPO:$current_tag
done
- name: Log in to Azure China prod docker registry
if: ${{ github.event.inputs.deployEnvironment == 'production' }}
uses: docker/login-action@v3
with:
registry: ${{ secrets.AZURE_CHINA_PROD_HOSTNAME }}
username: ${{ secrets.AZURE_CHINA_PROD_USERNAME }}
password: ${{ secrets.AZURE_CHINA_PROD_PASSWORD }}
- name: Azure China (Prod) - Tag and Push
if: ${{ github.event.inputs.deployEnvironment == 'production' }}
run: |
IMAGE_TAGS_TO_PUSH=(
"${{ github.event.inputs.releaseVersion }}"
)
PROD_IMAGE_REPO="${{ secrets.AZURE_CHINA_PROD_HOSTNAME }}/${{ github.event.repository.name }}"
for current_tag in ${IMAGE_TAGS_TO_PUSH[@]}
do
docker tag $ECR_DEV_IMAGE $PROD_IMAGE_REPO:$current_tag
docker push $PROD_IMAGE_REPO:$current_tag
done