Skip to content

Made the subscriber a bit more efficient #32

Made the subscriber a bit more efficient

Made the subscriber a bit more efficient #32

name: Subscriber deployment
on:
push:
branches:
- dev
- prod
permissions:
id-token: write
contents: read
env:
PRODUCT: nuklaivm
APPLICATION: subscriber
API_PORT: 8080
RPC_PORT: 50051
AWS_REGION: ${{ vars.AWS_REGION }}
ENVIRONMENT: ${{ vars.ENVIRONMENT }}
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
TASK_CPU: ${{ vars.TASK_CPU }}
TASK_MEMORY: ${{ vars.TASK_MEMORY }}
BUILD_FOLDER: build
jobs:
build_and_deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/prod' && 'prod' || github.ref == 'refs/heads/dev' && 'dev' || 'dev' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Upgrade deployment files with environment information
uses: cschleiden/replace-tokens@v1
with:
tokenPrefix: '${'
tokenSuffix: '}'
files: '["infra/aws/*.json"]'
env:
AWS_ACCOUNT_ID: ${{ env.AWS_ACCOUNT_ID }}
AWS_REGION: ${{ env.AWS_REGION }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.PRODUCT }}-${{ env.APPLICATION }}-deployer-${{ env.AWS_REGION }}-${{ env.ENVIRONMENT }}
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
env:
ECR_REGISTRY: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
ECR_REPOSITORY: ${{ env.PRODUCT }}-${{ env.APPLICATION }}-${{ env.ENVIRONMENT }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: infra/aws/task-definition-${{ env.APPLICATION }}.json
container-name: ${{ env.APPLICATION }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.APPLICATION }}
cluster: ${{ env.PRODUCT }}-${{ env.APPLICATION }}-${{ env.ENVIRONMENT }}
wait-for-service-stability: true