Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/rtd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,24 @@ jobs:
PROJECT_STATUS=$(curl -sS -o /tmp/rtd-project.json -w "%{http_code}" -X PATCH \
-H "Authorization: Token $RTD_TOKEN" \
-H "Content-Type: application/json" \
-d '{"repository":{"url":"https://github.com/layer1labs/specsmith.git","type":"git"},"default_branch":"main","homepage":"https://github.com/layer1labs/specsmith"}' \
-d '{"repository":{"url":"https://github.com/layer1labs/specsmith","type":"git"},"default_branch":"main","homepage":"https://github.com/layer1labs/specsmith"}' \
"https://readthedocs.org/api/v3/projects/specsmith/")
echo "RTD project update: HTTP $PROJECT_STATUS"
cat /tmp/rtd-project.json
[ "$PROJECT_STATUS" = "204" ] || { echo "::error::RTD project update failed."; exit 1; }

PROJECT_STATE_STATUS=$(curl -sS -o /tmp/rtd-project-state.json -w "%{http_code}" \
-H "Authorization: Token $RTD_TOKEN" \
"https://readthedocs.org/api/v3/projects/specsmith/")
[ "$PROJECT_STATE_STATUS" = "200" ] || { echo "::error::RTD project verification failed with HTTP $PROJECT_STATE_STATUS."; cat /tmp/rtd-project-state.json; exit 1; }
PROJECT_REPOSITORY=$(python -c "import json; print(json.load(open('/tmp/rtd-project-state.json'))['repository']['url'])")
PROJECT_BRANCH=$(python -c "import json; print(json.load(open('/tmp/rtd-project-state.json'))['default_branch'])")
case "$PROJECT_REPOSITORY" in
https://github.com/layer1labs/specsmith|https://github.com/layer1labs/specsmith.git) ;;
*) echo "::error::RTD project repository is '$PROJECT_REPOSITORY', not layer1labs/specsmith."; exit 1 ;;
esac
[ "$PROJECT_BRANCH" = "main" ] || { echo "::error::RTD project default branch is '$PROJECT_BRANCH', not main."; exit 1; }

SYNC_STATUS=$(curl -sS -o /tmp/rtd-sync.json -w "%{http_code}" -X POST \
-H "Authorization: Token $RTD_TOKEN" \
"https://readthedocs.org/api/v3/projects/specsmith/sync-versions/")
Expand Down
5 changes: 4 additions & 1 deletion tests/test_rtd_deploy_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ def test_rtd_deploy_uses_canonical_project_and_main() -> None:
Path(__file__).resolve().parents[1] / ".github" / "workflows" / "rtd-deploy.yml"
).read_text(encoding="utf-8")

assert "https://github.com/layer1labs/specsmith.git" in workflow
assert "https://github.com/layer1labs/specsmith" in workflow
assert '"default_branch":"main"' in workflow
assert "rtd-project-state.json" in workflow
assert "PROJECT_REPOSITORY" in workflow
assert "PROJECT_BRANCH" in workflow
assert "projects/specsmith/sync-versions/" in workflow
assert '[ "$PROJECT_STATUS" = "204" ]' in workflow
assert '[ "$SYNC_STATUS" = "202" ]' in workflow
Expand Down
Loading