1+ # Triggers documentation repository workflow when Polymesh main branch is updated
2+ # Uses GitHub API directly for cross-repository communication
3+ name : Trigger Documentation Update on Polymesh develop Update
4+
5+ on :
6+ push :
7+ branches : [ develop ]
8+
9+ jobs :
10+ trigger-docs-update :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Trigger documentation repository workflow
14+ env :
15+ GITHUB_TOKEN : ${{ secrets.DOCS_REPO_TRIGGER_TOKEN }}
16+ TARGET_REPO : " PolymeshAssociation/polymesh-core-docs"
17+ EVENT_TYPE : " polymesh-develop-updated"
18+ run : |
19+ #!/bin/bash
20+ # Script to trigger repository dispatch event in documentation repository
21+ # Uses GitHub REST API for secure cross-repository communication
22+
23+ # Validate required environment variables
24+ if [[ -z "$GITHUB_TOKEN" ]]; then
25+ echo "Error: DOCS_REPO_TRIGGER_TOKEN secret is required"
26+ exit 1
27+ fi
28+
29+ if [[ -z "$TARGET_REPO" ]]; then
30+ echo "Error: TARGET_REPO environment variable is required"
31+ exit 1
32+ fi
33+
34+ # Prepare payload with current commit information
35+ PAYLOAD=$(cat <<EOF
36+ {
37+ "event_type": "$EVENT_TYPE",
38+ "client_payload": {
39+ "polymesh_ref": "$GITHUB_SHA",
40+ "polymesh_branch": "$GITHUB_REF_NAME",
41+ "polymesh_repository": "$GITHUB_REPOSITORY",
42+ "triggered_by": "$GITHUB_ACTOR",
43+ "workflow_run_id": "$GITHUB_RUN_ID",
44+ "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
45+ }
46+ }
47+ EOF
48+ )
49+
50+ echo "Triggering documentation update in repository: $TARGET_REPO"
51+ echo "Event type: $EVENT_TYPE"
52+ echo "Polymesh commit SHA: $GITHUB_SHA"
53+
54+ # Send repository dispatch event using GitHub API
55+ HTTP_STATUS=$(curl -s -w "%{http_code}" -o response.json \
56+ -X POST \
57+ -H "Accept: application/vnd.github.v3+json" \
58+ -H "Authorization: token $GITHUB_TOKEN" \
59+ -H "User-Agent: GitHub-Actions-Trigger" \
60+ -d "$PAYLOAD" \
61+ "https://api.github.com/repos/$TARGET_REPO/dispatches")
62+
63+ # Check response status
64+ if [[ "$HTTP_STATUS" -eq 204 ]]; then
65+ echo "✅ Successfully triggered documentation update in $TARGET_REPO"
66+ else
67+ echo "❌ Failed to trigger workflow. HTTP Status: $HTTP_STATUS"
68+ echo "Response:"
69+ cat response.json
70+ exit 1
71+ fi
72+
73+ # Clean up temporary files
74+ rm -f response.json
0 commit comments