GitHub Action
commited on
Commit
·
b32dc9f
1
Parent(s):
7491220
Sync from GitHub with Git LFS
Browse files
scripts/publish_to_hashnode.py
CHANGED
|
@@ -49,7 +49,13 @@ def file_hash(path):
|
|
| 49 |
def graphql_request(query, variables):
|
| 50 |
headers = {"Authorization": f"Bearer {HASHNODE_TOKEN}"}
|
| 51 |
response = requests.post(API_URL, json={"query": query, "variables": variables}, headers=headers)
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
if response.status_code != 200:
|
| 54 |
raise Exception(f"GraphQL request failed with {response.status_code}: {response.text}")
|
| 55 |
if "errors" in resp_json:
|
|
@@ -57,6 +63,7 @@ def graphql_request(query, variables):
|
|
| 57 |
return resp_json
|
| 58 |
|
| 59 |
|
|
|
|
| 60 |
def create_post(title, slug, html):
|
| 61 |
query = """
|
| 62 |
mutation CreatePost($input: CreateStoryInput!) {
|
|
|
|
| 49 |
def graphql_request(query, variables):
|
| 50 |
headers = {"Authorization": f"Bearer {HASHNODE_TOKEN}"}
|
| 51 |
response = requests.post(API_URL, json={"query": query, "variables": variables}, headers=headers)
|
| 52 |
+
try:
|
| 53 |
+
resp_json = response.json()
|
| 54 |
+
except json.JSONDecodeError:
|
| 55 |
+
raise Exception(f"GraphQL вернул не JSON: {response.text}")
|
| 56 |
+
|
| 57 |
+
print("DEBUG: GraphQL response:", json.dumps(resp_json, indent=2)) # 🔹 печать ответа
|
| 58 |
+
|
| 59 |
if response.status_code != 200:
|
| 60 |
raise Exception(f"GraphQL request failed with {response.status_code}: {response.text}")
|
| 61 |
if "errors" in resp_json:
|
|
|
|
| 63 |
return resp_json
|
| 64 |
|
| 65 |
|
| 66 |
+
|
| 67 |
def create_post(title, slug, html):
|
| 68 |
query = """
|
| 69 |
mutation CreatePost($input: CreateStoryInput!) {
|