Implementing test for the api #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy FastAPI Application | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
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: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
# Add your commands to execute tests here | |
# Example: | |
# pytest tests/ | |
echo "done!" | |
deploy: | |
needs: test | |
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 | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
sudo systemctl stop paper_scrapper.service | |
sudo systemctl enable paper_scrapper.service | |
sudo systemctl start paper_scrapper.service | |
sudo systemctl status paper_scrapper.service | |
- name: Wait for deployment to complete | |
run: sleep 10 |