A webhook自动发布支持Coding

pull/480/head
vapao 2022-04-18 22:54:39 +08:00
parent bd9f6f2e3b
commit 708bba9b33
2 changed files with 9 additions and 2 deletions

View File

@ -52,6 +52,9 @@ def _parse_request(request):
elif 'X-Hub-Signature-256' in request.headers:
token = request.headers['X-Hub-Signature-256'].replace('sha256=', '')
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
token = request.GET.get('token')
repo = 'Gitlab'
@ -63,6 +66,10 @@ def _parse_request(request):
en_api_key = hmac.new(api_key.encode(), request.body, hashlib.sha256).hexdigest()
if token != en_api_key:
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:
return None, None
@ -75,7 +82,7 @@ def _parse_request(request):
def _parse_message(body, repo):
message = None
if repo in ['Gitee', 'Github']:
if repo in ['Gitee', 'Github', 'Coding']:
message = body.get('head_commit', {}).get('message', '')
elif repo in ['Gitlab', 'Codeup', 'Gogs']:
if body.get('commits'):

View File

@ -98,7 +98,7 @@ export default observer(function AutoDeploy() {
<div style={{color: '#ff4d4f'}}>请指定分支名称</div>
</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>
</Form.Item>
)}