Ferdigheter · Apper
Deploy from Git
Connect an app to a GitHub repository or GitLab project so every push to its branch deploys, and pull requests get previews.
A linked app deploys the newest commit on one branch each time someone pushes to it, and each pull request (or merge request on GitLab) gets its own preview. Skybu fetches the commit, keeps only the app's folder, and builds it exactly like an upload. The organisation must already have GitHub or GitLab connected; agents cannot connect them.
In short
get_github_statusandget_gitlab_statusto see what is connected. If nothing is, the user connects it in the dashboard first.list_github_reposorlist_gitlab_reposto find the repository's exact name.create_app_from_gitfor a new app, orlink_git_repofor an app that exists.- Follow the first deployment with
get_appandget_deploymentuntil it islive.
Step 1: is GitHub or GitLab connected?
{ "name": "get_github_status", "arguments": {} }
configured: false means this Skybu installation has no GitHub App; use GitLab or an upload instead. An empty installations list means the organisation has not connected GitHub. The answer also gives previewsPerApp.
{ "name": "get_gitlab_status", "arguments": {} }
Lists the GitLab connections, each with its address (gitlab.com or a self-managed GitLab) and tokenExpiresAt.
If the one the user needs is missing, tell them to connect it under Settings → Integrations at https://platform.skybu.no/#/org/settings/integrations:
- GitHub: "Connect GitHub" installs the Skybu GitHub App. They choose which repositories it may read.
- GitLab: an access token with the
apiscope, best a group access token with the Maintainer role, which keeps working when people leave. The CLI does the same:skybu gitlab connect [--url <address>] < token.
Never ask the user to paste a token into the conversation; there is no tool that takes one.
Step 2: find the repository
{ "name": "list_github_repos", "arguments": {} }
{ "name": "list_gitlab_repos", "arguments": {} }
GitHub lists what the App's installations can read. GitLab lists only projects where the token's user has at least the Maintainer role, because Skybu adds a webhook to the project when it is linked. A repository that is not in the list cannot be linked: the user gives the GitHub App access to it, or a GitLab user with more rights connects.
Step 3: create or link the app
A new app, deployed from the branch at once:
{
"name": "create_app_from_git",
"arguments": {
"projectId": "<project id>",
"name": "web",
"repo": "nordlys/kundeportal",
"branch": "main",
"rootDir": "apps/web",
"dataClass": "personal"
}
}
An existing app:
{ "name": "link_git_repo", "arguments": { "appId": "<app id>", "repo": "nordlys/kundeportal", "branch": "main" } }
| Argument | Meaning |
|---|---|
repo | owner/repo on GitHub, or the full path on GitLab (group/subgroup/project). |
provider | github or gitlab. Only needed when both have a repository with that name (repo_ambiguous). |
branch | Pushes to this branch deploy to production. Default main. |
rootDir | Build from this folder, for a monorepo. Default: the repository's root. |
dataClass, department, owner | As for any new app: ask the user (skill://apps/deploy-an-app). |
The folder is all the build sees: its package.json, lockfile or Dockerfile must be inside it. Several apps can link the same repository, one folder each. Linking again changes the branch or folder and keeps the previews.
link_git_repo does not deploy. To deploy the branch now, without waiting for a push:
{ "name": "deploy_latest_commit", "arguments": { "appId": "<app id>" } }
Step 4: follow the deployment
create_app_from_git returns appId, the address and deployment with its number and commit; deploy_latest_commit returns the number and commit. Get the deployment's id from get_app, which lists the newest deployments, then poll get_deployment as in skill://apps/deploy-an-app. If deployment is null, the app was created but its first deploy did not start; deploy_latest_commit tries again and says why it cannot. A failed build keeps the previous version serving (skill://apps/fix-a-failed-deploy).
What happens on a push
- A push to the linked branch deploys that commit to every app linked to the repository and branch. The deployment records the commit, its message, author and branch.
- Skybu posts a commit status (
skybu/<app>) that goes from building to deployed or failed. - If the organisation requires approval for production, the build waits as
awaiting_approvaland the commit status says so (skill://apps/previews-and-approval). - A commit with nothing in the root folder becomes a failed deployment saying so. So does a source over 50 MB after the folder is selected.
Pull request previews
Opening a pull request, or pushing to one, deploys its head commit to a preview at <app>-pr-<n>.<org>.skybu.app. The preview gets the app's preview variables and, when the project has a database, its own empty database. Closing or merging the pull request deletes the preview. Pull requests from forks get no preview, and at most a few previews run per app at once. See skill://apps/previews-and-approval.
Unlinking
{ "name": "unlink_git_repo", "arguments": { "appId": "<app id>" } }
Pushes stop deploying and the app's previews are deleted, with their databases. Confirm with the user first.
Things to know
get_git_linkshows the linked repository, branch, folder and a link to it, ornull.- Errors:
repo_not_accessible(no installation or connection can reach it),gitlab_forbidden(the token's user is not Maintainer),branch_not_foundorgitlab_not_found(check the branch),not_linked(no repository on the app),invalid_root_dir(give a relative path inside the repository). - GitLab tokens expire. When
tokenExpiresAtis near or past, the user replaces the token in the dashboard or withskybu gitlab token <connection id> < token; linked projects keep working. - Disconnecting GitHub or GitLab unlinks its repositories and deletes their previews.
- Variables for the build and the running app are set on the app, not in the repository (
skill://apps/environment-variables).