Skip to content

Merge pull request #6 from amirbabaei97/development #18

Merge pull request #6 from amirbabaei97/development

Merge pull request #6 from amirbabaei97/development #18

Workflow file for this run

name: Deploy FastAPI Application
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Set up Python (latest stable version)
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Checkout code
uses: actions/checkout@v2
- name: Create .env file
run: |
echo "PROXIES=${{ secrets.PROXIES }}" > .env
echo "API_KEYS=${{ secrets.API_KEYS }}" >> .env
- name: Copy repository and .env to the server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
port: 22
source: "."
target: "/var/www/paper_scrapper"
- name: Execute deployment script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
debug: true
port: 22
script: |
cd /var/www/paper_scrapper
source venv/bin/activate
# Upgrade pip to the latest version
pip install --upgrade pip
# Install requirements
pip install -r requirements.txt
# Start the FastAPI application with Uvicorn in the background
# Stop the service if it's already running
sudo systemctl stop paper_scrapper.service
# Enable the service to start on boot
sudo systemctl enable paper_scrapper.service
# Start the new service
sudo systemctl start paper_scrapper.service
# Check the status of the service
sudo systemctl status paper_scrapper.service
- name: Wait for deployment to complete
run: sleep 10