Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] added deployment script #40

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OPENAI_AI_KEY=
OPENAI_MODEL_ID=gpt-3.5-turbo-1106
OPEN_AI_EMBEDDINGS_MODEL=text-embedding-ada-002
PORT=8080
PORT=8081
SERVER_PORT=3001
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Docker Build, Push and Deploy

on:
push:
branches:
- main

jobs:
build-push-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up environment variables
run: |
echo "OPENAI_AI_KEY=${{secrets.OPENAI_AI_KEY}}" >> .env
echo "OPENAI_MODEL_ID=${{secrets.OPENAI_MODEL_ID}}" >> .env
echo "OPEN_AI_EMBEDDINGS_MODEL=${{secrets.OPEN_AI_EMBEDDINGS_MODEL}}" >> .env
echo "PORT=${{secrets.PORT}}" >> .env
echo "SERVER_PORT=${{secrets.SERVER_PORT}}" >> .env
echo "TWILIO_ACCOUNT_SID=${{secrets.TWILIO_ACCOUNT_SID}}" >> .env
echo "TWILIO_AUTH_TOKEN=${{secrets.TWILIO_AUTH_TOKEN}}" >> .env
echo "TWILIO_NUMBER=${{secrets.TWILIO_NUMBER}}" >> .env
echo "TEST_RECEPIENT_NUMBER=${{secrets.TEST_RECEPIENT_NUMBER}}" >> .env

- name: Create SSH key file
run: echo -e "${{ secrets.EC2_SSH_KEY }}" > ~/ec2_key
env:
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}

- name: Set permissions for SSH key file
run: chmod 600 ~/ec2_key

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker images
run: |
docker-compose build
docker-compose push

- name: Copy environment file
run: scp -i ~/ec2_key -o StrictHostKeyChecking=no ./.env ec2-user@${{ secrets.EC2_IP }}:~/beckn-action-bot/.env

- name: Copy docker-compose.yml to the server
run: scp -i ~/ec2_key -o StrictHostKeyChecking=no ./docker-compose.yml ec2-user@${{ secrets.EC2_IP }}:~/beckn-action-bot/docker-compose.yml

- name: SSH into EC2 instance and deploy
run: |
ssh -i ~/ec2_key ec2-user@${{ secrets.EC2_IP }} '
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USER }}" --password-stdin &&
cd ~/beckn-action-bot/ &&
docker-compose pull &&
docker-compose up -d'
env:
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ services:
- redis-new
networks:
- beckn_action_bot_network
volumes:
- ./:/app
# volumes:
# - ./:/app

volumes:
index_data:
Expand Down
Loading