-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (145 loc) · 4.71 KB
/
deploy_to_environment.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Deploy to Environment
on:
workflow_call:
inputs:
env:
required: true
type: string
lambda_version:
required: true
type: string
force_cedarproxy:
required: true
type: boolean
default: false
env:
EASI_APP_NODE_VERSION: "16.14.0"
GIT_HASH: ${{ github.sha }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
ENV: ${{ inputs.env }}
permissions:
id-token: write
contents: read
jobs:
confirm_deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}_gate
steps:
- name: Confirm deploy
run: |
echo "Deploy confirmed! 🚀"
deploy_cedarproxy:
needs: [confirm_deploy]
uses: ./.github/workflows/deploy_cedarproxy.yml
secrets: inherit
with:
env: ${{ inputs.env }}
force_cedarproxy: ${{ inputs.force_cedarproxy }}
database_actions:
runs-on: ubuntu-latest
needs: confirm_deploy
environment: ${{ inputs.env }}
env:
APP_ENV: ${{ inputs.env }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-west-2
- name: Clean the database
if: ${{ contains(inputs.env, 'dev') && vars.ENABLE_DEV_DB_CLEAN == '1' }}
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: easi-db-clean
NEW_IMAGE_TAG: latest
TASK_FAMILY: "easi-app-db-clean-${{ inputs.env }}"
ECS_CLUSTER: "${{ inputs.env }}-easi-app"
SECURITY_GROUP_NAME: "ecs-easi-app-db-clean-${{ inputs.env }}"
run: |
export TASK_REVISION=$(./scripts/update_ecs_task_definition.sh)
./scripts/run_ecs_task.sh
- name: Backup the database
if: contains(inputs.env, 'impl') || contains(inputs.env, 'prod')
run: |
./scripts/rds-snapshot-app-db
- name: Run database migrations
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: easi-db-migrate
NEW_IMAGE_TAG: ${{ env.GIT_HASH }}
TASK_FAMILY: "easi-app-db-migrate-${{ inputs.env }}"
ECS_CLUSTER: "${{ inputs.env }}-easi-app"
SECURITY_GROUP_NAME: "ecs-easi-app-db-migrate-${{ inputs.env }}"
run: |
export TASK_REVISION=$(./scripts/update_ecs_task_definition.sh)
./scripts/run_ecs_task.sh
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch
deploy_backend:
needs: [database_actions]
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
env:
APP_ENV: ${{ inputs.env }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-west-2
- name: Deploy EASI ECS service
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: easi-backend
NEW_IMAGE_TAG: ${{ env.GIT_HASH }}
TASK_FAMILY: "easi-app-${{ inputs.env }}"
ECS_CLUSTER: "${{ inputs.env }}-easi-app"
SERVICE_NAME: easi-app
run: |
export TASK_REVISION=$(./scripts/update_ecs_task_definition.sh)
./scripts/deploy_ecs_service.sh
- name: Wait for /healthcheck to return new version
env:
APP_ENV: ${{ inputs.env }}
NEW_IMAGE_TAG: ${{ env.GIT_HASH }}
run: |
./scripts/healthcheck "$NEW_IMAGE_TAG"
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch
deploy_frontend:
needs: [database_actions]
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
env:
APP_ENV: ${{ inputs.env }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-west-2
- name: Download Frontend assets
uses: actions/download-artifact@v4
with:
name: ${{ inputs.env }}-frontend-assets
path: build/
- name: Release assets to S3
env:
STATIC_S3_BUCKET: ${{ secrets.STATIC_S3_BUCKET }}
run: |
./scripts/release_static.sh
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch