From efd5086077e91be0b4754e54b55ea89e25d49c53 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:01:10 +0530 Subject: [PATCH 01/12] Create test.py --- test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..02cade2 --- /dev/null +++ b/test.py @@ -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'Hello, World!', response.data) + +if __name__ == '__main__': + unittest.main() From 6680474f22b586be6688d3169a479742d5e513b5 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:18:40 +0530 Subject: [PATCH 02/12] Create deploy.yml --- .github/workflows/deploy.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f2418d2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,25 @@ +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 requirements.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: run Flask-app + run: python app.py + From d345168f5dae5042d61a3a5e164fb3d620f10e15 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:20:01 +0530 Subject: [PATCH 03/12] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f2418d2..eebe5ef 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 - name: run requirements - run: pip install -r requirements.txt + run: pip install -r requirement.txt - name: Print debugging information run: | echo "Python Version: $(python --version)" From b634bcc7142dd922b525754ca15e903271d5a557 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:21:59 +0530 Subject: [PATCH 04/12] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 02cade2..93299c1 100644 --- a/test.py +++ b/test.py @@ -9,7 +9,7 @@ def setUp(self): def test_hello_world(self): response = self.client.get('/') self.assertEqual(response.status_code, 200) - self.assertIn(b'Hello, World!', response.data) + self.assertIn(b'

Hello World app! Version 1

', response.data) if __name__ == '__main__': unittest.main() From 91bd683755fa6128a76e8a5dce79720b8c24499e Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:45:54 +0530 Subject: [PATCH 05/12] Update deploy.yml --- .github/workflows/deploy.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index eebe5ef..71a5b24 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 - name: run requirements - run: pip install -r requirement.txt + run: pip install -r requirements.txt - name: Print debugging information run: | echo "Python Version: $(python --version)" @@ -20,6 +20,12 @@ jobs: echo "Contents of Working Directory: $(ls -l)" - name: test case run: python test.py - - name: run Flask-app - run: python app.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 root@15.206.84.164:/root/test/ && + ssh -o StrictHostKeyChecking=no -i private_key root@15.206.84.164 ' + python app.py + ' From c53ee7b16f6ccaef45313acdd0268e4a81759f4b Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:46:49 +0530 Subject: [PATCH 06/12] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 71a5b24..1e1577d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ jobs: - name: Setup python uses: actions/setup-python@v2 - name: run requirements - run: pip install -r requirements.txt + run: pip install -r requirement.txt - name: Print debugging information run: | echo "Python Version: $(python --version)" From cca4f4147d9811db128471bb0c672df1c98d3e21 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:52:02 +0530 Subject: [PATCH 07/12] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1e1577d..329c716 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: 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 root@15.206.84.164:/root/test/ && + rsync -azP -e "ssh -i private_key -o StrictHostKeyChecking=no" app.py root@15.206.84.164:/root/test/ && ssh -o StrictHostKeyChecking=no -i private_key root@15.206.84.164 ' python app.py ' From 79b3cf7dae68f2cd2568edae57af8643aeedf494 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:54:06 +0530 Subject: [PATCH 08/12] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 329c716..bb96829 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,5 +27,5 @@ jobs: echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key && rsync -azP -e "ssh -i private_key -o StrictHostKeyChecking=no" app.py root@15.206.84.164:/root/test/ && ssh -o StrictHostKeyChecking=no -i private_key root@15.206.84.164 ' - python app.py + python3 app.py ' From feb32b3eb60d5a7a5d8d9ecd030b9374475e80b4 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:56:34 +0530 Subject: [PATCH 09/12] Update deploy.yml --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bb96829..b6060a9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,5 +27,6 @@ jobs: echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key && rsync -azP -e "ssh -i private_key -o StrictHostKeyChecking=no" app.py root@15.206.84.164:/root/test/ && ssh -o StrictHostKeyChecking=no -i private_key root@15.206.84.164 ' + cd /root/test/ python3 app.py ' From a4f25624c786cf2c2c0b0f57e55c906bd641eb28 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:01:15 +0530 Subject: [PATCH 10/12] Update deploy.yml --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b6060a9..163856e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,8 +25,9 @@ jobs: 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 root@15.206.84.164:/root/test/ && + 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 ' From a203f1fee3a0dd1ecc5f94b9e1fe58d3033136e0 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:09:24 +0530 Subject: [PATCH 11/12] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 348152e..9c330f0 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,7 @@ @app.route("/") def hello(): - return "

Hello World app! Version 1

" + return "

Superstar sarojkumar

" if __name__ == "__main__": app.run(host='0.0.0.0',port=5000) From aaac0ac6090476c619f1ab2859dc3a16006fda67 Mon Sep 17 00:00:00 2001 From: Varun TM <126582315+Varun-TM@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:10:32 +0530 Subject: [PATCH 12/12] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 93299c1..858749e 100644 --- a/test.py +++ b/test.py @@ -9,7 +9,7 @@ def setUp(self): def test_hello_world(self): response = self.client.get('/') self.assertEqual(response.status_code, 200) - self.assertIn(b'

Hello World app! Version 1

', response.data) + self.assertIn(b'

Superstar sarojkumar

', response.data) if __name__ == '__main__': unittest.main()