mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-15 19:42:04 +08:00
test
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# Discourse Docs Sync — one-way push from docs_sp/ Markdown to Discourse API.
|
||||
#
|
||||
# WARNING: This workflow is strictly for Discourse API syncing.
|
||||
# Do NOT add Zensical build steps, GitHub Pages deployment, or any
|
||||
# static-site generation to this file. Those belong in docs.yaml.
|
||||
|
||||
name: Sync Docs to Discourse
|
||||
|
||||
on:
|
||||
@@ -17,8 +23,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install uv
|
||||
run: pip install uv
|
||||
- name: Setup environment
|
||||
run: ./tools/op.sh setup
|
||||
|
||||
- name: Smoke test - post one doc to Discourse
|
||||
env:
|
||||
@@ -46,13 +52,13 @@ jobs:
|
||||
# Extract title from front matter or first heading
|
||||
title = None
|
||||
for line in raw.splitlines():
|
||||
s = line.strip()
|
||||
if s.startswith('title:'):
|
||||
title = s[len('title:'):].strip().strip('\"').strip(\"'\")
|
||||
break
|
||||
if s.startswith('# '):
|
||||
title = s[2:].strip()
|
||||
break
|
||||
s = line.strip()
|
||||
if s.startswith('title:'):
|
||||
title = s[len('title:'):].strip().strip('\"').strip(\"'\")
|
||||
break
|
||||
if s.startswith('# '):
|
||||
title = s[2:].strip()
|
||||
break
|
||||
title = f'{title or \"What is sunnypilot?\"} - sunnypilot Docs'
|
||||
|
||||
print(f'Title: {title}')
|
||||
@@ -63,27 +69,27 @@ jobs:
|
||||
|
||||
cat_id = client.get_category_id()
|
||||
if cat_id is None:
|
||||
print(f'ERROR: Category not found on {config.base_url}')
|
||||
sys.exit(1)
|
||||
print(f'ERROR: Category not found on {config.base_url}')
|
||||
sys.exit(1)
|
||||
|
||||
existing = client.find_topic_by_sync_id(DOC_PATH)
|
||||
if existing is not None:
|
||||
topic_id = existing['id']
|
||||
post_id = client.first_post_id(topic_id)
|
||||
if post_id is None:
|
||||
print(f'ERROR: No first post for topic {topic_id}')
|
||||
sys.exit(1)
|
||||
result = client.update_post(post_id, body, edit_reason='CI smoke test')
|
||||
if result is None:
|
||||
print('ERROR: Failed to update post')
|
||||
sys.exit(1)
|
||||
print(f'Updated: {config.base_url}/t/{topic_id}')
|
||||
topic_id = existing['id']
|
||||
post_id = client.first_post_id(topic_id)
|
||||
if post_id is None:
|
||||
print(f'ERROR: No first post for topic {topic_id}')
|
||||
sys.exit(1)
|
||||
result = client.update_post(post_id, body, edit_reason='CI smoke test')
|
||||
if result is None:
|
||||
print('ERROR: Failed to update post')
|
||||
sys.exit(1)
|
||||
print(f'Updated: {config.base_url}/t/{topic_id}')
|
||||
else:
|
||||
result = client.create_topic(title=title, raw=body, category_id=cat_id, tags=['docs-auto-sync'])
|
||||
if result is None:
|
||||
print('ERROR: Failed to create topic')
|
||||
sys.exit(1)
|
||||
print(f'Created: {config.base_url}/t/{result.get(\"topic_id\", \"?\")}')
|
||||
result = client.create_topic(title=title, raw=body, category_id=cat_id, tags=['docs-auto-sync'])
|
||||
if result is None:
|
||||
print('ERROR: Failed to create topic')
|
||||
sys.exit(1)
|
||||
print(f'Created: {config.base_url}/t/{result.get(\"topic_id\", \"?\")}')
|
||||
|
||||
print('Smoke test passed!')
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user