diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..163856e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 + ' 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 "