diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml new file mode 100644 index 0000000..24c527c --- /dev/null +++ b/.github/workflows/playground.yml @@ -0,0 +1,21 @@ +name: playground + +on: + push: + branches: [ master ] + +jobs: + deploy: + environment: + name: Playground + url: https://playground.pysnippet.org/fastapi-oauth2 + runs-on: ubuntu-latest + steps: + - name: Run deployment script on server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY_ED25519 }} + port: ${{ secrets.PORT }} + script: sh ~/fastapi-oauth2/examples/demonstration/deploy.sh diff --git a/README.md b/README.md index a0a3575..f868a56 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # fastapi-oauth2 [![PyPI](https://img.shields.io/pypi/v/fastapi-oauth2.svg)](https://pypi.org/project/fastapi-oauth2/) +[![Playground](https://img.shields.io/badge/playground-blue.svg?logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNzEzNTE0OTc5MTUzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE2MjciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTc2OCA1MDYuMDI2NjY3djExLjk0NjY2NmEzMi40MjY2NjcgMzIuNDI2NjY3IDAgMCAxLTE1Ljc4NjY2NyAyNy43MzMzMzRMMzcwLjM0NjY2NyA3NjhjLTIzLjA0IDEzLjY1MzMzMy0zNC45ODY2NjcgMTMuNjUzMzMzLTQ1LjIyNjY2NyA3LjY4bC0xMC42NjY2NjctNS45NzMzMzNhMzIuNDI2NjY3IDMyLjQyNjY2NyAwIDAgMS0xNS43ODY2NjYtMjYuODhWMjgxLjE3MzMzM2EzMi40MjY2NjcgMzIuNDI2NjY3IDAgMCAxIDE1Ljc4NjY2Ni0yNy43MzMzMzNsMTAuNjY2NjY3LTUuOTczMzMzYzEwLjI0LTUuOTczMzMzIDIyLjE4NjY2Ny01Ljk3MzMzMyA1Mi4wNTMzMzMgMTEuNTJsMzc1LjA0IDIxOS4zMDY2NjZhMzIuNDI2NjY3IDMyLjQyNjY2NyAwIDAgMSAxNS43ODY2NjcgMjcuNzMzMzM0eiIgcC1pZD0iMTYyOCIgZGF0YS1zcG0tYW5jaG9yLWlkPSJhMzEzeC5zZWFyY2hfaW5kZXguMC5pMS40NzE5M2E4MVdiYjYyWiIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiI+PC9wYXRoPjwvc3ZnPg==)](https://playground.pysnippet.org/fastapi-oauth2/) [![Python](https://img.shields.io/pypi/pyversions/fastapi-oauth2.svg?logoColor=white)](https://pypi.org/project/fastapi-oauth2/) [![FastAPI](https://img.shields.io/badge/fastapi-%E2%89%A50.68.1-009486)](https://pypi.org/project/fastapi-oauth2/) [![Tests](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/tests.yml/badge.svg)](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/tests.yml) diff --git a/build.sh b/build.sh index 8e7b34c..f8c01cb 100644 --- a/build.sh +++ b/build.sh @@ -3,5 +3,5 @@ pip install build # build the wheel and install it -WHEEL_NAME=$(python -m build | grep -Po "fastapi_oauth2-.*\.whl" | tail -n 1) +WHEEL_NAME=$(python -m build | grep -Po "fastapi_oauth2-\S*\.whl" | tail -n 1) pip install dist/$WHEEL_NAME \ No newline at end of file diff --git a/examples/demonstration/deploy.sh b/examples/demonstration/deploy.sh new file mode 100644 index 0000000..e04fe71 --- /dev/null +++ b/examples/demonstration/deploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash +cd ~/fastapi-oauth2/ +git restore . +git pull + +cd ~/fastapi-oauth2/examples/demonstration +echo "import main; from fastapi import FastAPI; app = FastAPI(); app.mount('/fastapi-oauth2', main.app)" > playground.py + +sudo rm -r /var/www/playground/fastapi-oauth2/ +sudo cp -r ~/fastapi-oauth2/examples/demonstration /var/www/playground/fastapi-oauth2/ +sudo python3 -m pip install -r /var/www/playground/fastapi-oauth2/requirements.txt + +# Update environment variables for production +ENV_FILE=/var/www/playground/fastapi-oauth2/.env +for ENV_KEY in OAUTH2_GITHUB_CLIENT_ID OAUTH2_GITHUB_CLIENT_SECRET OAUTH2_GOOGLE_CLIENT_ID OAUTH2_GOOGLE_CLIENT_SECRET; +do + sudo python3 -c "from dotenv import set_key; set_key('${ENV_FILE}', '${ENV_KEY}', '${!ENV_KEY}')"; +done + +sudo service playground.fastapi-oauth2 restart diff --git a/examples/demonstration/requirements.txt b/examples/demonstration/requirements.txt new file mode 100644 index 0000000..4e9dc16 --- /dev/null +++ b/examples/demonstration/requirements.txt @@ -0,0 +1,9 @@ +fastapi +httpx>=0.23.0 +oauthlib>=3.2.2 +python-jose>=3.3.0 +social-auth-core>=4.4.2 +starlette>=0.19.1 +sqlalchemy +python-dotenv +fastapi-oauth2 \ No newline at end of file