forked from terra-money/terraswap-graph
-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (121 loc) · 4.83 KB
/
dashboard.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
name: Dashboard server
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "src/collector/**"
- "src/graphql/**"
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
ECR_REPOSITORY: terraswap-graph
ECS_CLUSTER: terraswap-graph
# terra mainnet
PHOENIX_ECS_SERVICE: phoenix-terraswap-graph-dashboard
PHOENIX_TASK_DEFINITION: phoenix-terraswap-graph-dashboard
PHOENIX_CONTAINER_NAME: phoenix-terraswap-graph-dashboard
# terra classic
COLUMBUS_ECS_SERVICE: columbus-terraswap-graph-dashboard
COLUMBUS_TASK_DEFINITION: columbus-terraswap-graph-dashboard
COLUMBUS_CONTAINER_NAME: columbus-terraswap-graph-dashboard
permissions:
id-token: write
contents: read
jobs:
build:
name: build terraswap-graph image
runs-on: ubuntu-latest
environment: production
outputs:
image-tag: ${{ steps.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: terraswap-graph-dashbaord-build
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
working-directory: .
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker image push -a $ECR_REGISTRY/$ECR_REPOSITORY
echo "image-tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
deploy-phoenix-dashboard:
name: Deploy Phoenix Dashboard
runs-on: ubuntu-latest
needs: build
environment: production
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: terraswap-graph-dashboard-phoenix
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Download Task Definition
id: download-task-definition
working-directory: .
run: |
aws ecs describe-task-definition --task-definition ${{ env.PHOENIX_TASK_DEFINITION }} | jq '.taskDefinition' > ${{ env.PHOENIX_TASK_DEFINITION }}.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/[email protected]
with:
task-definition: ./${{ env.PHOENIX_TASK_DEFINITION }}.json
container-name: ${{ env.PHOENIX_CONTAINER_NAME }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY}}:${{ needs.build.outputs.image-tag }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/[email protected]
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.PHOENIX_ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
deploy-columbus-dashboard:
name: Deploy Columbus Dashboard
runs-on: ubuntu-latest
needs: build
environment: production
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: terraswap-graph-dashboard-columbus
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]
- name: Download Task Definition
id: download-task-definition
working-directory: .
run: |
aws ecs describe-task-definition --task-definition ${{ env.COLUMBUS_TASK_DEFINITION }} | jq '.taskDefinition' > ${{ env.COLUMBUS_TASK_DEFINITION }}.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/[email protected]
with:
task-definition: ./${{ env.COLUMBUS_TASK_DEFINITION }}.json
container-name: ${{ env.COLUMBUS_CONTAINER_NAME }}
image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY}}:${{ needs.build.outputs.image-tag }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/[email protected]
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.COLUMBUS_ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true