workflow fix ssh #16
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: Continuous Deployment | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.x | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
python3 -m pytest | |
- name: Add Linode server to known hosts | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keyscan 172.233.46.163 >> ~/.ssh/known_hosts | |
- name: Deploy to Linode | |
if: ${{ success() }} | |
run: | | |
ssh root@172.233.46.163 'cd /var/www/html/ && git pull origin main && systemctl restart gunicorn && systemctl restart nginx && gunicorn main:app --bind 0.0.0.0' |