forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (140 loc) · 5.99 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
name: Push Development
on:
push:
branches:
- "development"
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@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
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 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 Server 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 Scheduler Task Definition
- name: Download Worker Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Workers --query taskDefinition > workers-task-definition.json
- name: Modify Amazon ECS task definition with AdHocWorker Container
id: render-adhocworker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: workers-task-definition.json
container-name: AdHocWorker
image: ${{ steps.build-image.outputs.image }}
- name: Modify Amazon ECS task definition with Worker Container
id: render-worker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-adhocworker-container.outputs.task-definition }}
container-name: Worker
image: ${{ steps.build-image.outputs.image }}
- name: Modify Amazon ECS task definition with ScheduledWorker Container for Production
id: render-scheduledworker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-worker-container.outputs.task-definition }}
container-name: ScheduledWorker
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-scheduledworker-container.outputs.task-definition }}
service: Workers
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true