Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 351750f

Browse files
committed
Debug deploy status management code
1 parent cc9dcce commit 351750f

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

.github/workflows/detect_pull_request_preview.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ jobs:
77
- uses: actions/checkout@v1
88
- name: Install dependency
99
run: pip install requests
10-
- name: Detect deployment
10+
- name: Debug deployment
1111
run:
12-
./tools/ci/pr_preview.py
13-
--host http://api.github.com
14-
--github-project web-platform-tests/wpt-actions-test
15-
detect
16-
--target http://s92097608.onlinehome.us/tmp
17-
--timeout 600
12+
./tools/ci/debug_deploy.py
1813
env:
1914
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}

tools/ci/debug_deploy.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python
2+
3+
import json
4+
import os
5+
6+
import requests
7+
8+
def gh_request(method_name, url, body=None):
9+
github_token = os.environ.get('GITHUB_TOKEN')
10+
11+
kwargs = {
12+
'headers': {
13+
'Authorization': 'token {}'.format(github_token),
14+
'Accept': 'application/vnd.github.v3+json'
15+
}
16+
}
17+
method = getattr(requests, method_name.lower())
18+
19+
if body is not None:
20+
kwargs['json'] = body
21+
22+
print 'Issuing request: {} {}'.format(method_name.upper(), url)
23+
print 'Request body: {}'.format(json.dumps(kwargs, indent=2))
24+
25+
resp = method(url, **kwargs)
26+
27+
resp.raise_for_status()
28+
29+
resp_body = resp.json()
30+
print 'Response status code: {}'.format(resp.status_code)
31+
print 'Response body: {}'.format(json.dumps(resp_body, indent=2))
32+
33+
return resp.json()
34+
35+
with open(os.environ['GITHUB_EVENT_PATH']) as handle:
36+
data = json.loads(handle.read())
37+
38+
print 'Event data: {}'.format(json.dumps(data, indent=2))
39+
40+
url_base = 'https://api.github.com/repos/web-platform-tests/wpt-actions-test'
41+
42+
gh_request(
43+
'GET',
44+
'{}/deployments/{}/statuses'.format(url_base, data['deployment']['id'])
45+
)
46+
47+
gh_request(
48+
'POST',
49+
'{}/deployments/{}/statuses'.format(url_base, data['deployment']['id']),
50+
{'state': 'pending'}
51+
)
52+
53+
gh_request(
54+
'GET',
55+
'{}/deployments/{}/statuses'.format(url_base, data['deployment']['id'])
56+
)

0 commit comments

Comments
 (0)