Skip to content

Commit

Permalink
Modif ci-cd.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ingcloud-fr committed Jul 31, 2024
1 parent c9a8024 commit b0c2c8f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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

0 comments on commit b0c2c8f

Please sign in to comment.