Deploy Relayers to Devnet - by @MakMuftic #225
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Licensed Work is (c) 2022 Sygma | |
# SPDX-License-Identifier: LGPL-3.0-only | |
name: Sygma Devnet | |
on: | |
push: | |
branches: | |
- main | |
run-name: Deploy Relayers to Devnet - ${{ inputs.release_tag }} by @${{ github.actor }} | |
env: | |
ENVIRONMENT: STAGE | |
REGISTRY: 'ghcr.io' | |
TAG: 'latest' | |
jobs: | |
push: | |
name: push | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: checkout the source code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: login to ghcr | |
id: ghcr | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: build / tag / push docker image into ghcr | |
id: build-and-push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.TAG }} | |
- name: slack notify | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,job,eventName,ref,workflow # selectable (default: repo,message) | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required | |
if: always() | |
######################## region 1 ######################## | |
deploy_reg_1: | |
needs: push | |
name: deploy region 1 | |
runs-on: ubuntu-latest | |
environment: devnet | |
strategy: | |
matrix: | |
relayer_id: [1] | |
env: | |
AWS_DEVNET: '${{ secrets.AWS_DEVNET }}' | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: checkout ecs repo | |
uses: actions/checkout@v3 | |
with: | |
repository: sygmaprotocol/devops | |
token: ${{ secrets.GHCR_TOKEN }} | |
- name: render jinja2 templates to task definition json files | |
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 }}.json' | |
data_format: json | |
variables: | | |
relayerId=${{ matrix.relayer_id }} | |
awsAccountId=${{ env.AWS_DEVNET }} | |
awsRegion=${{ secrets.AWS_REGION_1 }} | |
awsEfs=${{ secrets.DEVNET_EFS_1 }} | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: arn:aws:iam::${{ env.AWS_DEVNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge | |
aws-region: ${{ secrets.AWS_REGION_1 }} | |
role-session-name: GithubActions | |
- name: deploy 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: slack notify | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,job,eventName,ref,workflow # selectable (default: repo,message) | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required | |
if: always() | |
######################## region 3 ######################## | |
deploy_reg_3: | |
needs: push | |
name: deploy region 3 | |
runs-on: ubuntu-latest | |
environment: devnet | |
strategy: | |
matrix: | |
relayer_id: [4] | |
env: | |
AWS_DEVNET: '${{ secrets.AWS_DEVNET }}' | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: checkout ecs repo | |
uses: actions/checkout@v3 | |
with: | |
repository: sygmaprotocol/devops | |
token: ${{ secrets.GHCR_TOKEN }} | |
- name: render jinja2 templates to task definition json files | |
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 }}.json' | |
data_format: json | |
variables: | | |
relayerId=${{ matrix.relayer_id }} | |
awsAccountId=${{ env.AWS_DEVNET }} | |
awsRegion=${{ secrets.AWS_REGION_3 }} | |
awsEfs=${{ secrets.DEVNET_EFS_3 }} | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: arn:aws:iam::${{ env.AWS_DEVNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge | |
aws-region: ${{ secrets.AWS_REGION_3 }} | |
role-session-name: GithubActions | |
- name: deploy 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: slack notify | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,job,eventName,ref,workflow # selectable (default: repo,message) | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required | |
if: always() |