Skip to content

Create GitHub Actions for auto deployment to AWS #1

Create GitHub Actions for auto deployment to AWS

Create GitHub Actions for auto deployment to AWS #1

Workflow file for this run

name: Deploy Backend Services to Amazon ECS
on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ] # Temporary for testing
types: [ 'opened' ]
env:
AWS_REGION: ap-southeast-1
# ECR_REPOSITORY: question
# ECS_SERVICE: question-service
# ECS_CLUSTER: backend-cluster
# ECS_TASK_DEFINITION: question
# CONTAINER_NAME: question
jobs:
deploy:
name: Deploy Question Service
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::491085383176:role/GitHubAction-AssumeRoleWithAction
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Sts GetCallerIdentity
run: |
aws sts get-caller-identity
# - name: Build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker build -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@c804dfbdd57f713b6c079302a4c01db7017a36fc
# with:
# task-definition: ${{ env.ECS_TASK_DEFINITION }}
# container-name: ${{ env.CONTAINER_NAME }}
# image: ${{ steps.build-image.outputs.image }}
# - name: Deploy Amazon ECS task definition
# uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
# with:
# task-definition: ${{ steps.task-def.outputs.task-definition }}
# service: ${{ env.ECS_SERVICE }}
# cluster: ${{ env.ECS_CLUSTER }}
# wait-for-service-stability: true