forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (168 loc) · 7.35 KB
/
push_development.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Push Development
on:
push:
branches:
- "development"
permissions:
contents: read
id-token: write
pull-requests: write
actions: write
env:
ECR_REPOSITORY: images
IMAGE_TAG: ${{ github.sha }}
jobs:
prepare:
name: Prepare
runs-on: ubuntu-20.04
outputs:
BRANCH_REF_SLUG: ${{ steps.branch_ref_slug.outputs.slug }}
if: startsWith( github.ref, 'refs/heads/dependabot/' ) != true
steps:
- uses: actions/checkout@v3
- name: Set branch ref slug
id: branch_ref_slug
run: |
SLUG=$(echo "${{ github.ref }}" |
iconv -t ascii//TRANSLIT |
sed -E 's#refs/[^\/]*/##' |
sed -E 's/[^a-zA-Z0-9]+/-/g' |
sed -E 's/^-+|-+$//g' |
tr A-Z a-z)
echo "BRANCH_REF_SLUG=$SLUG" >> $GITHUB_ENV
echo "slug=$SLUG" >> $GITHUB_OUTPUT
build:
name: Build
needs: [prepare]
environment:
name: ${{ needs.prepare.outputs.BRANCH_REF_SLUG }}
runs-on: ubuntu-20.04
if: startsWith( github.ref, 'refs/heads/dependabot/' ) != true
steps:
- uses: actions/checkout@v3
- name: Set Environment Specific Variables
run: |
echo "AWS_REGION="${{ vars.AWS_REGION }} >> $GITHUB_ENV
echo "ECS_CLUSTER="${{ vars.ECS_CLUSTER }} >> $GITHUB_ENV
echo "ECS_SERVICE="${{ vars.ECS_SERVICE }} >> $GITHUB_ENV
- uses: actions/setup-node@v2-beta
with:
node-version: "14"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::906503920888:role/github-actions-oidc-redash
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build \
--file Dockerfile \
-t $ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:redash_latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:redash_latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
### Download and Update Server Task Definition
- name: Download Server Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Server --query taskDefinition > server-task-definition.json
- name: Add New Image ID to Server Container
id: render-server-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: server-task-definition.json
container-name: Server
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Server task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-server-container.outputs.task-definition }}
service: server
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update Scheduler Task Definition
- name: Download Scheduler Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Scheduler --query taskDefinition > scheduler-task-definition.json
- name: Modify Amazon ECS task definition with Scheduler Container
id: render-scheduler-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: scheduler-task-definition.json
container-name: Scheduler
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Scheduler task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-scheduler-container.outputs.task-definition }}
service: scheduler
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update Default Worker Task Definition
- name: Download Default Worker Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2DefaultWorkers --query taskDefinition > default-workers-task-definition.json
- name: Modify Amazon ECS task definition with Default Worker Container
id: render-default-workers-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: default-workers-task-definition.json
container-name: Worker
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Default Worker task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-default-workers-container.outputs.task-definition }}
service: default_workers
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update Scheduled Worker Task Definition
- name: Download Scheduled Worker Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2ScheduledWorkers --query taskDefinition > scheduled-workers-task-definition.json
- name: Modify Amazon ECS task definition with Scheduled Worker Container
id: render-scheduled-workers-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: scheduled-workers-task-definition.json
container-name: ScheduledWorker
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Scheduled Worker task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-scheduled-workers-container.outputs.task-definition }}
service: scheduled_workers
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update AdHoc Worker Task Definition
- name: Download AdHoc Worker Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2AdHocWorkers --query taskDefinition > adhoc-workers-task-definition.json
- name: Modify Amazon ECS task definition with Adhoc Container
id: render-adhoc-workers-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: adhoc-workers-task-definition.json
container-name: AdHocWorker
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS AdHoc Workers task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-adhoc-workers-container.outputs.task-definition }}
service: adhoc_workers
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true