Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: multi region deployment #207

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/deploy_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ name: sygma/deploy/stage
on:
push:
branches:
- main
- test-multi-region

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_REGION_2: '${{ secrets.AWS_REGION_2 }}'
ENVIRONMENT: STAGE
ENVIRONMENT_2: TESTNET
AWS_STAGE: '${{ secrets.AWS_ARN }}'
REGISTRY: 'ghcr.io'
TAG: 'latest'
Expand Down Expand Up @@ -54,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
relayer_id: [0, 1, 2, 3, 4]
relayer_id: [0, 1, 2]

permissions:
contents: read
Expand All @@ -80,6 +82,19 @@ jobs:
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_STAGE }}
awsRegion=${{ env.AWS_REGION }}
awsEfs=${{ secrets.TESTNET_EFS_1 }}

- name: render jinja2 region 2 templates to task definition json files
uses: cuchi/jinja2-action@v1.2.0
with:
template: 'relayers/ecs/task_definition-${{ env.ENVIRONMENT_2 }}.j2'
output_file: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT_2 }}_2.json'
data_format: json
variables: |
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_STAGE }}
awsRegion=${{ env.AWS_REGION_2 }}
awsEfs=${{ secrets.TESTNET_EFS_2 }}

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -95,3 +110,18 @@ jobs:
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT }}'
cluster: 'relayer-${{ env.ENVIRONMENT }}'
wait-for-service-stability: true

- name: configure aws credentials REGION_2
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_STAGE }}:role/github-actions-${{ env.ENVIRONMENT_2 }}-chainbridge
aws-region: ${{ env.AWS_REGION_2 }}
role-session-name: GithubActions

- name: deploy task definition REGION_2
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT_2 }}_2.json'
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT_2 }}'
cluster: 'relayer-${{ env.ENVIRONMENT_2 }}'
wait-for-service-stability: true
35 changes: 32 additions & 3 deletions .github/workflows/deploy_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_REGION_2: '${{ secrets.AWS_REGION_2 }}'
ENVIRONMENT: 'TESTNET'
REGISTRY: 'ghcr.io'
TAG: 'stable'
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
repository: sygmaprotocol/devops
token: ${{ secrets.GHCR_TOKEN }}

- name: render jinja2 templates to task definition json files
- name: region_1
uses: cuchi/jinja2-action@v1.2.0
with:
template: 'relayers/ecs/task_definition-${{ env.ENVIRONMENT }}.j2'
Expand All @@ -87,18 +88,46 @@ jobs:
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_TESTNET }}
awsRegion=${{ env.AWS_REGION }}
awsEfs=${{ secrets.TESTNET_EFS_1 }}

- name: configure aws credentials
- name: region_2
uses: cuchi/jinja2-action@v1.2.0
with:
template: 'relayers/ecs/task_definition-${{ env.ENVIRONMENT }}.j2'
output_file: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}_2.json'
data_format: json
variables: |
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_TESTNET }}
awsRegion=${{ env.AWS_REGION_2 }}
awsEfs=${{ secrets.TESTNET_EFS_2 }}

- name: configure aws credentials region_1
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_TESTNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge
aws-region: ${{ env.AWS_REGION }}
role-session-name: GithubActions

- name: deploy task definition
- name: deploy region_1 task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}.json'
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT }}'
cluster: 'relayer-${{ env.ENVIRONMENT }}'
wait-for-service-stability: true

- name: configure aws credentials region_2
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_TESTNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge
aws-region: ${{ env.AWS_REGION_2 }}
role-session-name: GithubActions

- name: deploy region_2 task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}_2.json'
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT }}'
cluster: 'relayer-${{ env.ENVIRONMENT }}'
wait-for-service-stability: true
Loading