From f9cd308c34751c8b904bcab5dd7c8bf7a315caa4 Mon Sep 17 00:00:00 2001 From: Carol Br Date: Sat, 7 Dec 2024 20:35:03 -0300 Subject: [PATCH] Test version tag with SemVer --- README.md | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 64bc5183..8df14f28 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,18 @@ Você encontrará todos os passos do nosso projeto através deste link na nossa ![Interrogate](docs/assets/interrogate_badge.svg) ## Desenvolvido com -* [![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)](https://docs.python.org/3/) -* [![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi)](https://fastapi.tiangolo.com/) -* [![Kubernetes](https://img.shields.io/badge/Kubernetes-326CE5?style=for-the-badge&logo=Kubernetes&logoColor=white)](https://kubernetes.io/pt-br/docs/home/) -* [![Docker](https://img.shields.io/badge/docker-257bd6?style=for-the-badge&logo=docker&logoColor=white)](https://docs.docker.com/) -* [![PostgresSQL](https://img.shields.io/badge/postgresql-4169e1?style=for-the-badge&logo=postgresql&logoColor=white)](https://www.postgresql.org/docs/) -* [![Typed with: pydantic](https://img.shields.io/badge/typed%20with-pydantic-BA600F.svg?style=for-the-badge)](https://docs.pydantic.dev/) + +- [![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)](https://docs.python.org/3/) +- [![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi)](https://fastapi.tiangolo.com/) +- [![Kubernetes](https://img.shields.io/badge/Kubernetes-326CE5?style=for-the-badge&logo=Kubernetes&logoColor=white)](https://kubernetes.io/pt-br/docs/home/) +- [![Docker](https://img.shields.io/badge/docker-257bd6?style=for-the-badge&logo=docker&logoColor=white)](https://docs.docker.com/) +- [![PostgresSQL](https://img.shields.io/badge/postgresql-4169e1?style=for-the-badge&logo=postgresql&logoColor=white)](https://www.postgresql.org/docs/) +- [![Typed with: pydantic](https://img.shields.io/badge/typed%20with-pydantic-BA600F.svg?style=for-the-badge)](https://docs.pydantic.dev/) --- ### Contribuição + [![Open Issues](https://img.shields.io/github/issues-raw/software-architecture-fiap/tech-challenge?style=for-the-badge)](https://github.com/software-architecture-fiap/tech-challenge/issues) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/software-architecture-fiap/tech-challenge?style=for-the-badge)](https://github.com/software-architecture-fiap/tech-challenge/issues?q=is%3Aissue+is%3Aclosed) [![Open Pulls](https://img.shields.io/github/issues-pr-raw/software-architecture-fiap/tech-challenge?style=for-the-badge)](https://github.com/software-architecture-fiap/tech-challenge/pulls) @@ -36,6 +38,7 @@ The pipeline [build-and-deploy](.github/workflows/build-and-deploy.yml) is desig > **Note:** This step is crucial to ensure a secure connection with AWS resources. Credentials are necessary for the pipeline to authenticate and interact with AWS ECR and EKS. Update the repository settings under `Secrets and variables` > `Actions` with the following values: + - `AWS_ACCESS_KEY_ID` - `AWS_SECRET_ACCESS_KEY` - `AWS_SESSION_TOKEN` @@ -43,12 +46,14 @@ Update the repository settings under `Secrets and variables` > `Actions` with th ## Workflow Triggers The pipeline is triggered by the following events: + - **Issue Comment**: When a comment is created, edited, or deleted on an issue that contains `/deploy-dev` - **Push**: When code is pushed to the `main` branch. ### Environment Variables The following environment variables are defined for use throughout the pipeline: + - `AWS_REGION`: The AWS region where resources are located (`us-east-1`). - `ECR_REPOSITORY`: The ECR repository name (`app/web`). - `EKS_CLUSTER_NAME`: The EKS cluster name (`EKS-lanchonete-cluster`). @@ -62,43 +67,53 @@ This job runs on `ubuntu-latest` and is executed if the event is an issue commen #### Steps 1. **Checkout Repository** + - Uses the `actions/checkout@v4` action to checkout the repository. 2. **Check for Deploy-Dev Comment** + - Checks if the event is an issue comment containing `/deploy-dev` and prints a message if true. 3. **Versioning Image** - - Determines the image tag based on the event type: - - Production: using `push` events to the `main` branch, increments the semantic version, considering the main branch as production. - - Development: it is trigger using the commit SHA with a `-dev` suffix. + + - Determines the image tag based on the event type: + - Production: using `push` events to the `main` branch, increments the semantic version, considering the main branch as production. + - Development: it is trigger using the commit SHA with a `-dev` suffix. 4. **Configure AWS Credentials** + - Uses the `aws-actions/configure-aws-credentials@v1` action to configure AWS credentials using secrets. 5. **Login to ECR Registry** + - Uses the `aws-actions/amazon-ecr-login@v1` action to log in to the ECR registry. 6. **Build and Push the Container Image** + - Builds and pushes the container image to the ECR repository using tag. 7. **Commit and Push Updated Version** + - Commits and pushes the updated version file if the event is a push to the `main` branch. 8. **Setup Kubeconfig** + - Sets up the kubeconfig for the EKS cluster using AWS CLI. 9. **Deploy Application to Kubernetes Cluster** - - Deploys the application to the Kubernetes cluster in the `development` namespace if the event is an issue comment containing `/deploy-dev`. - - Deploys the application to the `production` namespace on the EKS cluster when a commit is pushed to the `main` branch after merging a pull request. + - Deploys the application to the Kubernetes cluster in the `development` namespace if the event is an issue comment containing `/deploy-dev`. + - Deploys the application to the `production` namespace on the EKS cluster when a commit is pushed to the `main` branch after merging a pull request. ## Deployment Logic The deployment logic varies based on the environment: - - **Development Environment**: Triggered by issue comments containing `/deploy-dev`. - - **Production Environment**: Triggered by pushes to the `main` branch. + +- **Development Environment**: Triggered by issue comments containing `/deploy-dev`. +- **Production Environment**: Triggered by pushes to the `main` branch. The deployment process includes: - - Setting the environment and kustomize directory. - - Checking and creating the namespace if it doesn't exist. - - Updating the image in the kustomize configuration. - - Applying the Kubernetes resources using `kubectl`. + +- Setting the environment and kustomize directory. +- Checking and creating the namespace if it doesn't exist. +- Updating the image in the kustomize configuration. +- Applying the Kubernetes resources using `kubectl`.