From 452a96884435771d72fb1d7c044d0b3ed3515a93 Mon Sep 17 00:00:00 2001 From: kamillaker Date: Sat, 23 May 2026 20:28:39 +0200 Subject: [PATCH] add automatic ECS deployment to CI/CD pipeline --- .github/workflows/main.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 573574a..7e3a900 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: - name: Stop container run: docker stop fruit-api-test - + push-image: needs: build-and-test runs-on: ubuntu-latest @@ -92,4 +92,23 @@ jobs: - name: Build and push image run: | docker build -t ghcr.io/${{ github.repository_owner }}/fruit-api:latest ./fruit-api - docker push ghcr.io/${{ github.repository_owner }}/fruit-api:latest \ No newline at end of file + docker push ghcr.io/${{ github.repository_owner }}/fruit-api:latest + + deploy: + needs: push-image + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-1 + + - name: Deploy to ECS + run: | + aws ecs update-service \ + --cluster fruit-api-cluster \ + --service fruit-api-service \ + --force-new-deployment + \ No newline at end of file