DevOps
CI/CD for AWS ECS: Integrating with AWS CodePipeline or GitHub Actions
Option 1: GitHub Actions (Free Tier Friendly)
In repo .github/workflows/deploy.yml:
name: Deploy to ECSon: [push]jobs:deploy:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4- name: Configure AWSuses: aws-actions/configure-aws-credentials@v4with:aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}aws-region: us-west-2- name: Login to ECRid: login-ecruses: aws-actions/amazon-ecr-login@v2- name: Build, tag, pushenv:ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}ECR_REPOSITORY: my-app-repoIMAGE_TAG: latestrun: |docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG- name: Update ECSrun: |aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment
Add secrets in GitHub.
Option 2: CodePipeline
Using Console: CodePipeline > Create > Source: GitHub, Build: CodeBuild (Docker build spec), Deploy: ECS. Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.
Devops
Comment