|
91 | 91 | if pstr in dictionary:
|
92 | 92 | # get issue info
|
93 | 93 | issue_number = dictionary[pstr]
|
94 |
| - issue = repo.get_issue(number=issue_number) |
95 |
| - issue_url = issue.html_url |
96 |
| - issue_title = issue.title |
97 |
| - |
98 |
| - # content |
99 |
| - payload = {} |
100 |
| - payload['title'] = issue_title |
101 |
| - payload['body'] = issue_content |
102 |
| - |
103 |
| - # github edit issue api |
104 |
| - header = {'Authorization': 'token %s' % GITHUB_TOKEN} |
105 |
| - |
106 |
| - url = GITHUB_API + "/repos/" + GITHUB_REPO + "/issues/" + str(issue_number) |
107 |
| - r = requests.patch(url, headers=header, data=json.dumps(payload)) |
108 |
| - if r.status_code == 200: |
109 |
| - print("issue update successful: %s" % issue_number) |
110 |
| - else: |
111 |
| - print("issue update failed: %s" % issue_number) |
112 |
| - exit(-1) |
| 94 | + try: |
| 95 | + issue = repo.get_issue(number=issue_number) |
| 96 | + |
| 97 | + issue_url = issue.html_url |
| 98 | + issue_title = issue.title |
| 99 | + |
| 100 | + # content |
| 101 | + payload = {} |
| 102 | + payload['title'] = issue_title |
| 103 | + payload['body'] = issue_content |
| 104 | + |
| 105 | + # github edit issue api |
| 106 | + header = {'Authorization': 'token %s' % GITHUB_TOKEN} |
| 107 | + |
| 108 | + url = GITHUB_API + "/repos/" + GITHUB_REPO + "/issues/" + str(issue_number) |
| 109 | + r = requests.patch(url, headers=header, data=json.dumps(payload)) |
| 110 | + if r.status_code == 200: |
| 111 | + print("issue update successful: %s" % issue_number) |
| 112 | + else: |
| 113 | + print("issue update failed: %s" % issue_number) |
| 114 | + exit(-1) |
| 115 | + except GithubException as e: |
| 116 | + print('get issues: %s error, skip for next' % issue_number) |
113 | 117 |
|
114 | 118 | else:
|
115 | 119 | #creat issue
|
|
133 | 137 | repo.create_file(POST_INDEX_FILE, "add post index: _index", "{}", branch=GITHUB_BRANCH)
|
134 | 138 | #update POST_INDEX_FILE
|
135 | 139 | post_index_file = repo.get_contents(POST_INDEX_FILE,ref=GITHUB_BRANCH)
|
136 |
| -post_index_content = json.dumps(dictionary) |
| 140 | +post_index_content = json.dumps(dictionary, ensure_ascii=False) |
137 | 141 | post_index_msg = "rebuild posts index from: " + GITHUB_ACTION_NAME
|
138 | 142 | repo.update_file(post_index_file.path, post_index_msg, post_index_content, post_index_file.sha, branch=GITHUB_BRANCH)
|
139 | 143 |
|
|
0 commit comments