Skip to content

chore: change user based to role based #36

chore: change user based to role based

chore: change user based to role based #36

Workflow file for this run

name: Collector
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "src/dashboard/**"
- "src/graphql/**"
env:
AWS_REGION: ${{ secrets.COLLECTOR_AWS_REGION }}
ECR_REPOSITORY: terraswap-graph
ECS_CLUSTER: terraswap-graph
# terra mainnet
PHOENIX_ECS_SERVICE: phoenix-terraswap-graph-collector
PHOENIX_TASK_DEFINITION: phoenix-terraswap-graph-collector
PHOENIX_CONTAINER_NAME: phoenix-terraswap-graph-collector
# terra classic
COLUMBUS_ECS_SERVICE: columbus-terraswap-graph-collector
COLUMBUS_TASK_DEFINITION: columbus-terraswap-graph-collector
COLUMBUS_CONTAINER_NAME: columbus-terraswap-graph-collector
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-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-collector:
name: Deploy Phoenix Collector
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-collector-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-collector:
name: Deploy Columbus Collector
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-collector-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