Skip to content

Commit 2bd2844

Browse files
Set up an automated workflow for playground deployment (GH-40)
2 parents 4d565f4 + 14f8982 commit 2bd2844

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

.github/workflows/playground.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: playground
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
deploy:
9+
environment:
10+
name: Playground
11+
url: https://playground.pysnippet.org/fastapi-oauth2
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Run deployment script on server
15+
uses: appleboy/ssh-action@master
16+
with:
17+
host: ${{ secrets.HOST }}
18+
username: ${{ secrets.USERNAME }}
19+
key: ${{ secrets.KEY_ED25519 }}
20+
port: ${{ secrets.PORT }}
21+
script: sh ~/fastapi-oauth2/examples/demonstration/deploy.sh

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# fastapi-oauth2 <img src="https://github.com/pysnippet.png" align="right" height="64" />
22

33
[![PyPI](https://img.shields.io/pypi/v/fastapi-oauth2.svg)](https://pypi.org/project/fastapi-oauth2/)
4+
[![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/)
45
[![Python](https://img.shields.io/pypi/pyversions/fastapi-oauth2.svg?logoColor=white)](https://pypi.org/project/fastapi-oauth2/)
56
[![FastAPI](https://img.shields.io/badge/fastapi-%E2%89%A50.68.1-009486)](https://pypi.org/project/fastapi-oauth2/)
67
[![Tests](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/tests.yml/badge.svg)](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/tests.yml)

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
pip install build
44

55
# build the wheel and install it
6-
WHEEL_NAME=$(python -m build | grep -Po "fastapi_oauth2-.*\.whl" | tail -n 1)
6+
WHEEL_NAME=$(python -m build | grep -Po "fastapi_oauth2-\S*\.whl" | tail -n 1)
77
pip install dist/$WHEEL_NAME

examples/demonstration/deploy.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
cd ~/fastapi-oauth2/
3+
git restore .
4+
git pull
5+
6+
cd ~/fastapi-oauth2/examples/demonstration
7+
echo "import main; from fastapi import FastAPI; app = FastAPI(); app.mount('/fastapi-oauth2', main.app)" > playground.py
8+
9+
sudo rm -r /var/www/playground/fastapi-oauth2/
10+
sudo cp -r ~/fastapi-oauth2/examples/demonstration /var/www/playground/fastapi-oauth2/
11+
sudo python3 -m pip install -r /var/www/playground/fastapi-oauth2/requirements.txt
12+
13+
# Update environment variables for production
14+
ENV_FILE=/var/www/playground/fastapi-oauth2/.env
15+
for ENV_KEY in OAUTH2_GITHUB_CLIENT_ID OAUTH2_GITHUB_CLIENT_SECRET OAUTH2_GOOGLE_CLIENT_ID OAUTH2_GOOGLE_CLIENT_SECRET;
16+
do
17+
sudo python3 -c "from dotenv import set_key; set_key('${ENV_FILE}', '${ENV_KEY}', '${!ENV_KEY}')";
18+
done
19+
20+
sudo service playground.fastapi-oauth2 restart
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fastapi
2+
httpx>=0.23.0
3+
oauthlib>=3.2.2
4+
python-jose>=3.3.0
5+
social-auth-core>=4.4.2
6+
starlette>=0.19.1
7+
sqlalchemy
8+
python-dotenv
9+
fastapi-oauth2

0 commit comments

Comments
 (0)