mirror of https://github.com/openspug/spug
A webhook自动发布支持Coding
parent
bd9f6f2e3b
commit
708bba9b33
|
@ -52,6 +52,9 @@ def _parse_request(request):
|
||||||
elif 'X-Hub-Signature-256' in request.headers:
|
elif 'X-Hub-Signature-256' in request.headers:
|
||||||
token = request.headers['X-Hub-Signature-256'].replace('sha256=', '')
|
token = request.headers['X-Hub-Signature-256'].replace('sha256=', '')
|
||||||
repo = 'Github'
|
repo = 'Github'
|
||||||
|
elif 'X-Coding-Signature' in request.headers:
|
||||||
|
token = request.headers['X-Coding-Signature'].replace('sha1=', '')
|
||||||
|
repo = 'Coding'
|
||||||
elif 'token' in request.GET: # Compatible the old version of gitlab
|
elif 'token' in request.GET: # Compatible the old version of gitlab
|
||||||
token = request.GET.get('token')
|
token = request.GET.get('token')
|
||||||
repo = 'Gitlab'
|
repo = 'Gitlab'
|
||||||
|
@ -63,6 +66,10 @@ def _parse_request(request):
|
||||||
en_api_key = hmac.new(api_key.encode(), request.body, hashlib.sha256).hexdigest()
|
en_api_key = hmac.new(api_key.encode(), request.body, hashlib.sha256).hexdigest()
|
||||||
if token != en_api_key:
|
if token != en_api_key:
|
||||||
return None, None
|
return None, None
|
||||||
|
elif repo in ['Coding']:
|
||||||
|
en_api_key = hmac.new(api_key.encode(), request.body, hashlib.sha1).hexdigest()
|
||||||
|
if token != en_api_key:
|
||||||
|
return None, None
|
||||||
else:
|
else:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
@ -75,7 +82,7 @@ def _parse_request(request):
|
||||||
|
|
||||||
def _parse_message(body, repo):
|
def _parse_message(body, repo):
|
||||||
message = None
|
message = None
|
||||||
if repo in ['Gitee', 'Github']:
|
if repo in ['Gitee', 'Github', 'Coding']:
|
||||||
message = body.get('head_commit', {}).get('message', '')
|
message = body.get('head_commit', {}).get('message', '')
|
||||||
elif repo in ['Gitlab', 'Codeup', 'Gogs']:
|
elif repo in ['Gitlab', 'Codeup', 'Gogs']:
|
||||||
if body.get('commits'):
|
if body.get('commits'):
|
||||||
|
|
|
@ -98,7 +98,7 @@ export default observer(function AutoDeploy() {
|
||||||
<div style={{color: '#ff4d4f'}}>请指定分支名称。</div>
|
<div style={{color: '#ff4d4f'}}>请指定分支名称。</div>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
) : (
|
) : (
|
||||||
<Form.Item label="Webhook URL" extra="点击复制链接,目前支持Gitee、Github、Gitlab、Gogs和Codeup(阿里云)。">
|
<Form.Item label="Webhook URL" extra="点击复制链接,目前支持Gitee、Github、Gitlab、Gogs、Coding和Codeup(阿里云)。">
|
||||||
<div className={styles.webhook} onClick={() => copyToClipBoard(url)}>{url}</div>
|
<div className={styles.webhook} onClick={() => copyToClipBoard(url)}>{url}</div>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue