Skip to content

Update agents when transferring asset ownership (#1852) #10

Update agents when transferring asset ownership (#1852)

Update agents when transferring asset ownership (#1852) #10

# Triggers documentation repository workflow when Polymesh main branch is updated
# Uses GitHub API directly for cross-repository communication
name: Trigger Documentation Update on Polymesh develop Update
on:
push:
branches: [ develop ]
jobs:
trigger-docs-update:
runs-on: ubuntu-latest
steps:
- name: Trigger documentation repository workflow
env:
GITHUB_TOKEN: ${{ secrets.DOCS_REPO_TRIGGER_TOKEN }}
TARGET_REPO: "PolymeshAssociation/polymesh-core-docs"
EVENT_TYPE: "polymesh-develop-updated"
run: |
#!/bin/bash
# Script to trigger repository dispatch event in documentation repository
# Uses GitHub REST API for secure cross-repository communication
# Validate required environment variables
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "Error: DOCS_REPO_TRIGGER_TOKEN secret is required"
exit 1
fi
if [[ -z "$TARGET_REPO" ]]; then
echo "Error: TARGET_REPO environment variable is required"
exit 1
fi
# Prepare payload with current commit information
PAYLOAD=$(cat <<EOF
{
"event_type": "$EVENT_TYPE",
"client_payload": {
"polymesh_ref": "$GITHUB_SHA",
"polymesh_branch": "$GITHUB_REF_NAME",
"polymesh_repository": "$GITHUB_REPOSITORY",
"triggered_by": "$GITHUB_ACTOR",
"workflow_run_id": "$GITHUB_RUN_ID",
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
}
EOF
)
echo "Triggering documentation update in repository: $TARGET_REPO"
echo "Event type: $EVENT_TYPE"
echo "Polymesh commit SHA: $GITHUB_SHA"
# Send repository dispatch event using GitHub API
HTTP_STATUS=$(curl -s -w "%{http_code}" -o response.json \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "User-Agent: GitHub-Actions-Trigger" \
-d "$PAYLOAD" \
"https://api.github.com/repos/$TARGET_REPO/dispatches")
# Check response status
if [[ "$HTTP_STATUS" -eq 204 ]]; then
echo "✅ Successfully triggered documentation update in $TARGET_REPO"
else
echo "❌ Failed to trigger workflow. HTTP Status: $HTTP_STATUS"
echo "Response:"
cat response.json
exit 1
fi
# Clean up temporary files
rm -f response.json