Update first_tests.yml #93
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 Django to VM | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Set up environment | |
run: echo "Environment variables set" | |
env: | |
DB_NAME: ${{ secrets.DB_NAME }} | |
DB_USER: ${{ secrets.DB_USER }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
DB_HOST: ${{ secrets.DB_HOST }} | |
DB_PORT: ${{ secrets.DB_PORT }} | |
- name: Deploy to web_server_01 | |
uses: appleboy/ssh-action@v0.1.6 | |
with: | |
host: ${{ secrets.VM_HOST_1 }} | |
username: ubuntu | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
if [ -d "scholarly" ]; then | |
sudo systemctl stop scholarly.service | |
cp -r scholarly/media . | |
rm -rf scholarly | |
git clone https://github.com/mojalefakodisang/scholarly | |
rm -rf scholarly/media | |
mv ./media scholarly | |
cd scholarly | |
sudo apt-get install -y python3.8-venv | |
python3 -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
DB_NAME=${{ secrets.DB_NAME }} DB_USER=${{ secrets.DB_USER }} DB_HOST=localhost DB_PORT=${{ secrets.DB_PORT }} DB_PASSWORD=${{ secrets.DB_PASSWORD }} python3 -m manage makemigrations | |
DB_NAME=${{ secrets.DB_NAME }} DB_USER=${{ secrets.DB_USER }} DB_HOST=localhost DB_PORT=${{ secrets.DB_PORT }} DB_PASSWORD=${{ secrets.DB_PASSWORD }} python3 -m manage migrate | |
sudo systemctl restart scholarly.service | |
fi |