Skip to content

Commit 209d320

Browse files
committed
Add Release Webhook when tag is created on github.
1 parent 556ca2e commit 209d320

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mystbin/backend/routers/admin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import annotations
2020

2121
import datetime
22+
import subprocess
2223
from typing import Dict, Optional, Union
2324

2425
import psutil
@@ -241,6 +242,18 @@ async def get_server_stats(request: MystbinRequest):
241242
return UJSONResponse(data, status_code=200)
242243

243244

245+
@router.get("/admin/release_hook", tags=["admin"], include_in_schema=False)
246+
@limit("admin")
247+
async def get_server_stats(request: MystbinRequest):
248+
if not request.state.user or not request.state.user["admin"]:
249+
return UJSONResponse({"error": "Unauthorized"}, status_code=401)
250+
251+
command = 'cd /root/MystBin/; git pull;'
252+
subprocess.run(command, stdout=subprocess.PIPE, shell=True)
253+
254+
return UJSONResponse(data, status_code=200)
255+
256+
244257
@router.get(
245258
"/admin/pastes/{paste_id}",
246259
tags=["admin"],

0 commit comments

Comments
 (0)