Skip to content
Open
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
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Flask-app

on:
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v2
- name: run requirements
run: pip install -r requirement.txt
- name: Print debugging information
run: |
echo "Python Version: $(python --version)"
echo "Working Directory: $(pwd)"
echo "Contents of Working Directory: $(ls -l)"
- name: test case
run: python test.py
- name: deploy to server
env:
SSH_PRIVATE_KEY: ${{ secrets.SECRET_KEY }}
run: |
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key &&
rsync -azP -e "ssh -i private_key -o StrictHostKeyChecking=no" app.py requirement.txt root@15.206.84.164:/root/test/ &&
ssh -o StrictHostKeyChecking=no -i private_key root@15.206.84.164 '
cd /root/test/
pip3 install -r requirement.txt
python3 app.py
'
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@app.route("/")
def hello():
return "<h1><center> Hello World app! Version 1<center><h1>"
return "<h1><center> Superstar sarojkumar<center><h1>"

if __name__ == "__main__":
app.run(host='0.0.0.0',port=5000)
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest
from app import app

class TestHelloWorld(unittest.TestCase):

def setUp(self):
self.client = app.test_client()

def test_hello_world(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
self.assertIn(b'<h1><center> Superstar sarojkumar<center><h1>', response.data)

if __name__ == '__main__':
unittest.main()