Skip to content

refactor: Update workflow.yaml to use actions-awscli-v2 for deploying… #12

refactor: Update workflow.yaml to use actions-awscli-v2 for deploying…

refactor: Update workflow.yaml to use actions-awscli-v2 for deploying… #12

name: Continuos Integration -Testing, Build and Deploy Backend Catalog Microservice to AWS ECS
on:
pull_request:
push:
branches:
- main
env:
# Setting an environment variable with the value of a configuration variable
ECR_BACKEND_IMAGE: ${{ secrets.ECR_BACKEND_IMAGE }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
ECS_CLUSTER: ${{ secrets.ECS_CLUSTER }}
ECS_BACKEND_SERVICE: ${{ secrets.ECS_BACKEND_SERVICE }}
jobs:
continuos-integration:
name: Continuos Integration - Testing and Deploy
runs-on: ubuntu-latest
environment: production-catalog-microservice
steps:

Check failure on line 19 in .github/workflows/workflowTestingAndDeploy.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/workflowTestingAndDeploy.yaml

Invalid workflow file

You have an error in your yaml syntax on line 19
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
uses: actions/setup-python@v5
with:
python-version: '3.12.X'
- name: Install dependencies with poetry
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Install libs for testing
run: |
poetry install
- name: Run tests unit - Backend Catalog Microservice
run: |
poetry run pytest
- name: Configure AWS credentials to login to ECR
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: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR with Docker
run: |
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- name: Build and push Docker image to Amazon ECR
run: |
docker buildx create --use
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64 -t ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$ECR_BACKEND_IMAGE:latest --push .
- name: Deploy to ECS Backend Catalog Microservice
uses: imehedi/actions-awscli-v2@latest
with:
args: ecs update-service --cluster ${{ secrets.ECS_CLUSTER }} --service ${{ secrets.ECS_BACKEND_SERVICE }} --force-new-deployment
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}