Skip to content

Commit

Permalink
Refactor CICD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
vectornguyen76 committed Dec 1, 2024
1 parent 932b2c0 commit 1bb8d20
Show file tree
Hide file tree
Showing 19 changed files with 978 additions and 599 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

102 changes: 99 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,113 @@
# CI/CD Deploy

## Set up

### Create Secrets on Github

1. **AWS**

- AWS_ACCESS_KEY_ID: access token
- AWS_SECRET_ACCESS_KEY: secret access
- SSH_PRIVATE_KEY: ssh key pair

2. **Dockerhub**

- DOCKERHUB_USERNAME: username
- DOCKERHUB_PASSWORD: password

3. **Chat Service**

- OPENAI_API_KEY: your openai api key

4. **Frontend**

- GOOGLE_CLIENT_ID: google client id
- GOOGLE_CLIENT_SECRET: google client password
- NEXTAUTH_SECRET: nextauth secret

5. **Backend**
_Config env email_

- MAIL_HOST
- MAIL_PORT
- MAIL_USER
- MAIL_PASS
- MAIL_SENDER

_Config env JWT_

- AT_SECRET
- RT_SECRET

_Database url_

- DATABASE_URL

6. **Database**
- POSTGRES_USER: user name
- POSTGRES_PASSWORD: password
- POSTGRES_DB: database name

### Create Variables on Github

1. **AWS**

- TAGS: Tag for resources

Example:

```sh
[{ "Key": "ApplicationName", "Value": "Omni Assistant" },
{ "Key": "Purpose", "Value": "Learning" },
{ "Key": "Project", "Value": "Omni Assistant" },
{ "Key": "ProjectID", "Value": "Omni Assistant" },
{ "Key": "Creator", "Value": "VectorNguyen" },
{ "Key": "OwnerService", "Value": "VectorNguyen" }
]
```
2. **Backend**
_Config env Rate Limitting_
- RL_TTL
- RL_LIMIT
_Config refresh token, token time_
- EXP_AT
- EXP_RT
_Config env API for AI_
- ENDPOINT_AI
_Config CORS Socket_
- FRONTEND_URL
_Redis_
- REDIS_HOST
- REDIST_PORT
_Config port backend_
- PORT
## Workflows
### Development - Build and Unittest
#### File: [development_pipeline.yml](development_pipeline.yml)
**Event:** On Pull Request → any branch into develop
**Event:** On Commit or Pull Request → any branch into develop
**Jobs:**
- Install dependencies (caches)
- Run isort
- Run black
- Run flake8
- Build images (caches)
- Push images to Docker Hub
**Description:**
This workflow is triggered on Pull Requests into the develop branch. It ensures a clean and standardized codebase by installing dependencies, checking code formatting with isort, black, and flake8, and finally building and pushing Docker images to Docker Hub.
Expand Down Expand Up @@ -63,3 +155,7 @@ This pipeline is designed for the staging environment and is triggered on Pull R
**Description:**
The production pipeline is triggered on Pull Requests into the master branch, indicating changes are ready for deployment to the production environment. It follows a similar process to the staging pipeline but is specifically tailored for the production environment. The cleanup process adheres to the A/B deployment concept, ensuring a smooth transition between versions.
## References
- [Reusing workflows](https://docs.github.com/en/actions/sharing-automations/reusing-workflows)
4 changes: 2 additions & 2 deletions .github/workflows/ansible/deploy_applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
- text_search_image: vectornguyen76/text_search
- text_search_tag: latest

- backend_image: vectornguyen76/backend-search-engine
- backend_image: vectornguyen76/backend_search_engine
- backend_tag: latest

- frontend_image: vectornguyen76/frontend-search-engine
- frontend_image: vectornguyen76/frontend_search_engine
- frontend_tag: latest

pre_tasks:
Expand Down
Loading

0 comments on commit 1bb8d20

Please sign in to comment.