From 82e53739886070aef041b03950200acf6b2bdda1 Mon Sep 17 00:00:00 2001 From: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:17:02 +0530 Subject: [PATCH] Implement CI/CD pipeline Related to #1 Add CI/CD pipeline configuration and deployment commands. * **README.md** - Add a section on how to configure and use the CI/CD pipeline. - Include instructions for setting up environment variables for deployment. * **.github/workflows/ci-cd.yml** - Add specific deployment commands in the `deploy` job. - Include steps to deploy the application to a specified environment. * **.env** - Add environment variables required for deployment. --- .env | 5 +++ .github/workflows/ci-cd.yml | 12 ++++- README.md | 89 +++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 3b42c80..5b48574 100644 --- a/.env +++ b/.env @@ -38,3 +38,8 @@ WEATHER_API_ENDPOINT=your_weather_api_endpoint # News API NEWS_API_KEY=your_news_api_key NEWS_API_ENDPOINT=your_news_api_endpoint + +# Deployment Environment Variables +DEPLOYMENT_ENV=production +DEPLOYMENT_SERVER=your_deployment_server +DEPLOYMENT_PATH=/path/to/deployment diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2d7565b..27eb176 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -54,6 +54,16 @@ jobs: DHAN_API_KEY: ${{ secrets.DHAN_API_KEY }} DHAN_SECRET_KEY: ${{ secrets.DHAN_SECRET_KEY }} CHATGPT_API_KEY: ${{ secrets.CHATGPT_API_KEY }} + TELEGRAM_BOT_API_KEY: ${{ secrets.TELEGRAM_BOT_API_KEY }} + TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + WEATHER_API_KEY: ${{ secrets.WEATHER_API_KEY }} + WEATHER_API_ENDPOINT: ${{ secrets.WEATHER_API_ENDPOINT }} + NEWS_API_KEY: ${{ secrets.NEWS_API_KEY }} + NEWS_API_ENDPOINT: ${{ secrets.NEWS_API_ENDPOINT }} run: | # Deploy command or script here - echo "Deployment step - Placeholder. Add actual deployment commands here." + echo "Starting deployment..." + # Example deployment commands + # python deploy.py --env production + # ./scripts/deploy.sh + echo "Deployment completed." diff --git a/README.md b/README.md index 21f9e01..686bc50 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,92 @@ A robust, high-performance cryptocurrency trading bot built in Python that lever ### Installation 1. Clone the repository: + +```sh +git clone https://github.com/yourusername/nse-trading-bot.git +cd nse-trading-bot +``` + +2. Install dependencies: + +```sh +pip install -r requirements.txt +``` + +3. Set up environment variables: + +Create a `.env` file in the root directory of the project and add the following environment variables: + +```sh +# API keys +DHAN_API_KEY=your_dhan_api_key +DHAN_SECRET_KEY=your_dhan_secret_key +CHATGPT_API_KEY=your_chatgpt_api_key + +# WebSocket URL (Optional if the default URL is used) +DHAN_WEBSOCKET_URL=wss://api.dhan.co/ws/marketData + +# Logging +LOG_LEVEL=INFO + +# Email Notifications +NOTIFY_EMAIL=true +SMTP_SERVER=smtp.example.com +SMTP_PORT=587 +EMAIL_ADDRESS=your_email@example.com +EMAIL_PASSWORD=your_email_password +RECIPIENT_LIST=recipient1@example.com,recipient2@example.com + +# SMS Notifications (Optional) +NOTIFY_SMS=false +SMS_API_KEY=your_sms_api_key +SMS_API_SECRET=your_sms_api_secret +RECIPIENT_NUMBER=1234567890 + +# Logging configurations +LOG_FILE_PATH=logs/trading_bot.log +LOG_LEVEL=INFO + +# Telegram Notifications +TELEGRAM_BOT_API_KEY=your_telegram_bot_api_key +TELEGRAM_CHAT_ID=your_telegram_chat_id + +# Weather API +WEATHER_API_KEY=your_weather_api_key +WEATHER_API_ENDPOINT=your_weather_api_endpoint + +# News API +NEWS_API_KEY=your_news_api_key +NEWS_API_ENDPOINT=your_news_api_endpoint +``` + +## CI/CD Pipeline Configuration + +### Setting Up CI/CD Pipeline + +The CI/CD pipeline is configured using GitHub Actions. The workflow file is located at `.github/workflows/ci-cd.yml`. + +### Environment Variables for Deployment + +Ensure the following environment variables are set in your GitHub repository secrets: + +- `DHAN_API_KEY` +- `DHAN_SECRET_KEY` +- `CHATGPT_API_KEY` +- `TELEGRAM_BOT_API_KEY` +- `TELEGRAM_CHAT_ID` +- `WEATHER_API_KEY` +- `WEATHER_API_ENDPOINT` +- `NEWS_API_KEY` +- `NEWS_API_ENDPOINT` + +### Running the CI/CD Pipeline + +The CI/CD pipeline is triggered on every push to the `main` branch and on pull requests targeting the `main` branch. It includes jobs for testing and deployment. + +To manually trigger the pipeline, you can use the "Run workflow" button in the Actions tab of your GitHub repository. + +### Deployment Commands + +The deployment step in the CI/CD pipeline includes commands to deploy the application to a specified environment. Ensure you have the necessary deployment scripts and configurations in place. +