Srophé Application : Documentation
GitHub webhooks
The Srophe application provides a script for syncing both data and code repositories to your GitHub repository, making it easier for distributed contributions to be pushed to the website as they are made on GitHub.
github-xq library module: https://github.com/eXist-db/github-xq
Edit modules/git-sync.xql
to add details for your application and your GitHub repository. (Do not save these details to a GitHub repository)
githubxq:execute-webhook($data as item()*,
$application-path as xs:string,
$repo as xs:string,
$branch as xs:string?,
$key as xs:string,
$rateLimitToken as xs:string?)
Parameters:
- $data - Content of webhook POST request
- $application-path - Path to eXist-db application
- $repo - Path to GitHub repository
- $branch - GitHub branch to get data from
- $key - Private key for GitHub authentication ** https://developer.github.com/webhooks/securing/
- $rateLimitToken - Git Token used for rate limiting. This is optional. GitHub restricts wehhook activity to 60 unauthenticated requests per hour. ** https://developer.github.com/v3/#rate-limiting
Example:
let $data := request:get-data()
return
githubxq:execute-webhook($data,
'/db/apps/ba-data',
'https://github.com/wsalesky/blogs/',
'OPTIONAL-BRANCH',
'YOUR-SECRET-KEYE',
'OPTIONAL-RATE-LIMIT-KEY')
Note: The XQuery responding to GitHub must be run with elevated privileges in order to save and edit the files in your application.
Example: sm:chmod(xs:anyURI(xs:anyURI('YOUR-ENDPOINT.xql'), "rwsr-xr-x"))
Read about webhooks here: [https://developer.github.com/webhooks/]
Webhook settings:
- Payload URL: Full url to your endpoint. (example: http://5ba09277.ngrok.com/exist/apps/srophe/modules/git-sync.xql)
- Content type: application/json
- Secret: You will need to generate a secret key to verify webhook requests. See: https://developer.github.com/webhooks/securing/ Keep track of the secret, as it will have to be added the access-config.xml file, which is not stored in the github repository.
- Leave all the other default options checked