Skip to content

[Feat] Github App Deployment#1112

Merged
RichardAnderson merged 3 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/githubapp-deployment
May 22, 2026
Merged

[Feat] Github App Deployment#1112
RichardAnderson merged 3 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/githubapp-deployment

Conversation

@RichardAnderson

Copy link
Copy Markdown
Member

Implements site deployments for GitHub App via short-lived installation tokens injected through a git credential helper, plus a handful of pre-existing-bug fixes uncovered along the way.

Implemented a git credential helper - clone and pull operations now run through a credential.helper for GitHub App deployments, token is per-repo and the token only ever lives in env at exec-time, never on disk. Token is only valid for 1h. Using a git credential helper here allows existing deployment scripts authenticate for any required commands during the deployment without changes.

  • Removed OS::runScript's info($command) call — it was writing the full deploy script (and now the token env var) to laravel.log at INFO
  • AbstractSiteType::isolate() no longer guards createIsolatedUser on !userSharedWithSiblings() or !userExists() — the blade is fully idempotent and we need it to always run so existing isolated users (created before the auth-keys fix) get the server's public key installed into their authorized_keys.
  • Removed userExists() and check-user-exists.blade.php — became zero-callers after the isolate() guard was dropped.
  • SourceControl::siteValidationRules() now requires a Server — added user/project scoping to close a cross-tenant binding gap that became reachable once GitHub App was marked usableForSites(true).
  • create-isolated-user.blade.php now writes the server's public key to the isolated user's authorized_keys — fixes a pre-existing bug where the terminal/live-console couldn't SSH into any isolated user.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class site deployment support for GitHub App–backed source controls by switching Git operations to HTTPS with short-lived installation tokens provided via a git credential helper, while also tightening source control scoping and addressing a few deployment/SSH-related edge cases uncovered during implementation.

Changes:

  • Implement GitHub App deployment path: installation token minting/caching, injection via GIT_HTTP_TOKEN, and git credential helper setup (clone/fetch/set-remote).
  • Tighten source_control validation to be server-scoped (user + project) and allow GitHub App source controls to be used for sites.
  • Add GitHub App push webhook handling to trigger deployments asynchronously; fix isolated-user SSH key provisioning and remove sensitive script logging.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Feature/SitesTest.php Updates expectations and factories to include user scoping and new git quoting behavior.
tests/Feature/GithubAppTest.php Adds/updates feature tests covering GitHub App site create/update, env vars token injection, and push webhook deploy trigger.
tests/Feature/API/SitesTest.php Aligns API site creation tests with user-scoped SourceControl validation.
resources/views/ssh/site/check-user-exists.blade.php Removes unused SSH template after isolation behavior change.
resources/views/ssh/os/create-isolated-user.blade.php Makes isolated user creation idempotent and ensures server public key is present in authorized_keys.
resources/views/ssh/git/set-remote.blade.php Adds remote rewrite + credential helper toggle for token-based deployments.
resources/views/ssh/git/fetch-origin.blade.php Adjusts path handling for safer shell usage.
resources/views/ssh/git/clone.blade.php Adds token-based clone flow using credential helper; adjusts escaping/quoting in clone script.
resources/views/ssh/git/checkout.blade.php Adjusts escaping/quoting for branch/path.
app/SSH/OS/OS.php Escapes exported runScript variables; removes logging of full scripts; passes server public key into isolated-user creation.
app/SSH/OS/Git.php Routes clone/fetch/set-remote through token-aware env injection and shell-escaped args.
app/SourceControlProviders/GithubApp.php Implements required deployment surface (repo URL, hooks/keys no-ops) and installation access token minting/caching.
app/SiteTypes/PHPSite.php Updates site validation to require server-scoped source control rules.
app/SiteTypes/NodeJS.php Updates site validation to require server-scoped source control rules.
app/SiteTypes/MiseNodeJS.php Updates site validation to require server-scoped source control rules.
app/SiteTypes/MiseBun.php Updates site validation to require server-scoped source control rules.
app/SiteTypes/AbstractSiteType.php Skips deploy key for GitHub App sites; always runs isolated-user creation to reassert keys/permissions; removes user-existence helper.
app/Providers/SourceControlServiceProvider.php Enables GitHub App provider for site usage.
app/Models/SourceControl.php Changes site validation rules to be server-scoped (provider usable + user/project constraints).
app/Models/Site.php Adds GIT_HTTP_TOKEN to environment variables for GitHub App–backed sites.
app/Jobs/Site/TriggerDeployFromWebhookJob.php New job to trigger deployments from GitHub App push webhooks.
app/Jobs/Site/DeployJob.php Injects environment variables into modern deployment SSH step.
app/Http/Controllers/API/GithubAppWebhookController.php Routes push events to the new handler action.
app/Actions/Site/UpdateSourceControl.php Server-scoped validation; cleans up deploy keys/hooks on swap; rewrites git remote URL.
app/Actions/GithubApp/HandlePushWebhook.php New action to map push payloads to matching sites and enqueue deploy triggers.

Comment thread resources/views/ssh/git/clone.blade.php Outdated
Comment thread app/SSH/OS/OS.php
Comment thread app/Actions/Site/UpdateSourceControl.php Outdated
@saeedvaziry

Copy link
Copy Markdown
Member

Approved

@RichardAnderson RichardAnderson merged commit 9de2c98 into vitodeploy:4.x May 22, 2026
3 checks passed
@RichardAnderson RichardAnderson deleted the feat/githubapp-deployment branch May 22, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants