Skip to content

Modif ci-cd.yaml

Modif ci-cd.yaml #1

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-3
- name: Get AWS Account ID
id: aws-account
run: echo "ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> $GITHUB_ENV
- name: Log in to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
- name: Build and push Docker image
run: |
IMAGE_URI=${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-3.amazonaws.com/twitter_light:latest
docker build -t $IMAGE_URI .
docker push $IMAGE_URI
- name: Deploy to ECS
env:
AWS_REGION: eu-west-3
ECS_CLUSTER_NAME: twitter-stage-cluster
ECS_SERVICE_NAME: twitter-stage-service
IMAGE_URI: ${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-3.amazonaws.com/twitter_light:latest
run: |
aws ecs update-service --cluster $ECS_CLUSTER_NAME --service $ECS_SERVICE_NAME --force-new-deployment
environment:
name: staging