GitHub integration
In short
Read repositories and files, and work with issues and pull requests. Connect it on the Integrations page; your app then calls GitHub through Sapilon without ever holding a GitHub credential.
Lets your app read repositories, files, commits and releases, and open, update and comment on issues and pull requests, with a fine-grained personal access token.
Give the token only the repositories and permissions the app needs; GitHub enforces both.
Connecting
On the Integrations page choose Connect on GitHub and fill in:
- Fine-grained personal access token — github.com/settings/personal-access-tokens → Generate new token. Pick the repositories it may use and grant Contents, Issues and Pull requests (read, or read and write).
Sapilon checks the key with the provider before it saves it, and stores it encrypted; it is never shown again.
- A token belongs to a person: use a machine account for anything long-lived.
What your app can do
Only these requests are available; anything else is refused.
GET /userGET /user/reposGET /repos/*/*GET|POST /repos/*/*/issuesGET|PATCH /repos/*/*/issues/*GET|POST /repos/*/*/issues/*/commentsGET|POST /repos/*/*/pullsGET /repos/*/*/pulls/*GET /repos/*/*/contents/**GET /repos/*/*/commitsGET /repos/*/*/releases
How the agent uses it
Use integrations.request('github', …); paths are relative to https://api.github.com and the X-GitHub-Api-Version header is added for you. The token sees only the repositories it was given.
GET /user— the token’s account. Example:{ method: 'GET', path: '/user' }.GET /user/repos— repositories the token can see. Example:{ method: 'GET', path: '/user/repos', query: { per_page: '50' } }.GET /repos/{owner}/{repo}— one repository.GET|POST /repos/{owner}/{repo}/issues— list or open issues (pull requests appear in the list too). Example:{ method: 'POST', path: '/repos/acme/app/issues', body: { title: 'Login fails', body: 'Steps…', labels: ['bug'] } }.GET|PATCH /repos/{owner}/{repo}/issues/{number}— read, edit or close one issue. Example:{ method: 'PATCH', path: '/repos/acme/app/issues/42', body: { state: 'closed' } }.GET|POST /repos/{owner}/{repo}/issues/{number}/comments— Example:{ method: 'POST', path: '/repos/acme/app/issues/42/comments', body: { body: 'Fixed in 1.2' } }.GET|POST /repos/{owner}/{repo}/pulls,GET /repos/{owner}/{repo}/pulls/{number}— list, open or read pull requests.GET /repos/{owner}/{repo}/contents/{path}— a file (base64 inbody.content) or a folder listing. Example:{ method: 'GET', path: '/repos/acme/app/contents/docs/README.md' }.GET /repos/{owner}/{repo}/commits,GET /repos/{owner}/{repo}/releases— history and releases.
Lists page with query: { per_page, page }. Deleting is not allowed.
More from GitHub: https://docs.github.com/en/rest