File tree Expand file tree Collapse file tree 7 files changed +49
-22
lines changed
Expand file tree Collapse file tree 7 files changed +49
-22
lines changed Original file line number Diff line number Diff line change 1+ API_TOKEN = beep-boop
Original file line number Diff line number Diff line change @@ -128,4 +128,5 @@ dmypy.json
128128# Pyre type checker
129129.pyre /
130130
131- sites /* .json
131+ sites /* .json
132+ ! sites /example.com.json
Original file line number Diff line number Diff line change 1+ {
2+ "path" : " /home/projects/example.com" ,
3+ "release" : {
4+ "deploy" : " rsync -ai --delete --exclude='.git/' --exclude='.gitignore' /home/projects/example.com/ /www/html/example.com/"
5+ }
6+ }
Original file line number Diff line number Diff line change 11from auth import auth
22from parse import parse
33from quart import Quart , request
4-
4+ from dotenv import load_dotenv
5+ load_dotenv ()
56
67app = Quart (__name__ )
78
Original file line number Diff line number Diff line change 11import hmac
22import hashlib
33import os
4- from dotenv import load_dotenv
5- load_dotenv ()
6-
7- token = os .environ .get ("API_TOKEN" )
8- tokenb = bytes (token , 'utf-8' )
4+ import sys
95
106
117async def auth (header , data ):
8+ token = os .environ .get ("API_TOKEN" )
9+ tokenb = bytes (token , 'utf-8' )
10+
1211 signature = 'sha256=' + hmac .new (tokenb , data , hashlib .sha256 ).hexdigest ()
1312 if hmac .compare_digest (signature , header ):
1413 return True
1514 return False
15+
16+
17+ if __name__ == "__main__" :
18+ if len (sys .argv ) == 3 :
19+ body = sys .argv [1 ]
20+ header = sys .argv [2 ]
21+ if auth (header , body ):
22+ print ('true' )
23+ else :
24+ print ('false' )
25+ elif len (sys .argv ) == 2 :
26+ body = sys .argv [0 ]
27+ header = sys .argv [1 ]
28+ if auth (header , body ):
29+ print ('true' )
30+ else :
31+ print ('false' )
32+ else :
33+ print ('false' )
Original file line number Diff line number Diff line change 11from multiprocessing import Process
22from release import processRelease
3+ import sys
34
45
56async def parse (repo , payload ):
@@ -9,3 +10,13 @@ async def parse(repo, payload):
910 args = (repo , payload ))
1011 print (p .pid )
1112 p .start ()
13+
14+ if __name__ == "__main__" :
15+ if len (sys .argv ) == 3 :
16+ repo = sys .argv [1 ]
17+ payload = sys .argv [2 ]
18+ parse (repo , payload )
19+ elif len (sys .argv ) == 2 :
20+ repo = sys .argv [0 ]
21+ payload = sys .argv [1 ]
22+ parse (repo , payload )
Original file line number Diff line number Diff line change 11import json
22import subprocess
33
4- from os import path
5- from pathlib import Path
4+ from os import environ
65from pybars import Compiler
76
87compiler = Compiler ()
98
109
1110def processRelease (repo , payload ):
12- base_path = Path ( __file__ ). parent
11+ base_path = environ . get ( "SITES" )
1312 file_name = repo + '.json'
14- file_path = (base_path / '..' / 'sites' / file_name ).resolve ()
13+ file_path = (base_path / file_name ).resolve ()
1514
1615 with open (file_path ) as f :
1716 data = json .load (f )
1817
1918 if 'release' in data .keys () and 'path' in data .keys ():
2019 commands = []
21-
22- cwd = data ['cwd' ]
23-
24- if path .exists (base_path / '..' / '.nvmrc' ):
25- commands .append ('. ' + cwd + '/.nvm/nvm.sh' )
26- commands .append ('nvm use' )
27- elif 'node' in data .keys ():
28- commands .append ('. ' + cwd + '/.nvm/nvm.sh' )
29- commands .append ('nvm use ' + data ['node' ])
30-
3120 if 'build' in data ['release' ].keys ():
3221 source = data ['release' ]['build' ]
3322 template = compiler .compile (source )
@@ -60,4 +49,4 @@ def processRelease(repo, payload):
6049 process .communicate ()
6150 print ('Release complete!' )
6251
63- return
52+ return
You can’t perform that action at this time.
0 commit comments