Skip to content

Connecting to GitHub

Export and sync your Draftbit AI Builder app to a GitHub repository so you can version, collaborate on, and extend your code with your team.

Draftbit’s GitHub Export lets you push your app’s generated source code straight to a repository you own, so it lives alongside the rest of your engineering workflow. The GitHub Export integration commits your app’s generated source code (React Native, Astro, Vite, or a backend variant, depending on your app) to a repository and branch you choose, whenever you trigger an export.

You’ll need:

  • A Draftbit app you’d like to connect, on a workspace with the Pro plan or higher — GitHub Export is a Pro-tier feature.
  • A GitHub account with access to the destination repository.
  • Permission to create a personal access token on that GitHub account (fine-grained tokens are recommended).
  • An existing GitHub repository (empty or not) that you have push access to.
  1. Open your app in the AI Builder at next.draftbit.com.

  2. Find the GitHub Export destination. There are two entry points:

    • Export menu — click Export in the top toolbar, then select Setup next to the GitHub entry.
    • Publish Destinations — open Publishing → Publish Destinations, alongside App Store Connect, Google Play Console, and Custom Domain.
    The Export menu, with GitHub Export listed alongside Download Project The Publish Destinations page, with the Github Export card alongside other publish destinations

    From the Publishing page, click the Github Export card to open the Github Export Integration dialog, shown below.

    The Github Export Integration dialog with empty fields
  3. Create a GitHub personal access token. Draftbit authenticates to your repository with a token scoped to Contents: Read and Write on the target repo. If your app’s generated code includes a .github/workflows directory, also grant Workflows: Read and write — otherwise the export will fail trying to write those files, even to a branch that doesn’t have them yet.

    1. In the setup form, click the here link under the token field — this opens GitHub’s fine-grained token creation page.
    2. Give the token a recognizable name, for example draftbit-export.
    3. Under Repository access, select Only select repositories and choose your target repo.
    4. Under Permissions → Repository permissions, set Contents to Read and write (and Workflows to Read and write if your app’s generated code includes a .github/workflows directory).
    5. Click Generate token, then copy it immediately — GitHub only shows it once.
  4. Fill in the GitHub Export Integration form with your repository URL, branch name, and access token, then click Check Access. This confirms Draftbit can reach and read the repository — it only needs the repository URL and access token to enable, so you can check access before entering a branch name. It doesn’t push anything or confirm write access, so double-check the token was created with Contents: Read and Write as described above.

  5. Click Save Configuration to store your repository, branch, and token. This saves the connection but doesn’t push any code by itself.

  6. To push your code, open the Export menu in the top toolbar and click Commit next to the GitHub entry — this opens the export dialog. In the dialog, select Github from the Destination dropdown (it resets to blank each time the dialog opens, and Export stays disabled until a destination is chosen), then click Export to push your code to the configured branch. Larger apps can take a few minutes to push.

FieldWhat it’s forExample
GitHub Repository URL (required)The repository your exported code will be pushed to. A full URL or an org/repo slug both work — Draftbit validates it before saving.https://github.com/username/repository
GitHub Branch Name (required)The branch that receives each export. Use an existing branch, or a new name Draftbit can create on first push. Not required to check access, only to save.main or draftbit-export
GitHub Access Token (required)A personal access token with Contents: Read and Write permission on the target repository. Entered as a masked field.github_pat_••••••••

Validation errors for missing fields appear inline as soon as you start filling in the form. Check Access only needs the repository URL and access token to enable — the branch name isn’t required until you save. Save Configuration stays disabled until all three fields are valid:

The Github Export Integration dialog showing inline validation for empty required fields
  • Scope your token tightly. Use a fine-grained token limited to the one repository you’re exporting to, with Contents: Read and write enabled (plus Workflows: Read and write if your app’s generated code includes a .github/workflows directory) — avoid classic tokens with broad, account-wide access.
  • Use a dedicated branch you don’t hand-edit. Every export overwrites the entire contents of the target branch. Exporting to a branch like draftbit-export instead of main keeps generated pushes from clobbering code your team edits by hand.
  • Rotate tokens periodically. Set an expiration when you create the token and regenerate it periodically. Revoke it immediately from GitHub if it’s ever exposed.
  • Verify before you save. Click Check Access first to confirm Draftbit can reach and read the repository — it only needs the repository URL and token, so you can do this before filling in a branch name. It doesn’t verify write access, so also double-check the token has Contents: Read and Write before exporting.
You see thisHere’s what to do
”Branch name is required” / “GitHub access token is required”These inline messages appear as soon as you start filling in the form with a field still empty. Save Configuration stays disabled until all three fields are valid. Check Access only requires the repository URL and access token, so it can be used before a branch name is entered.
Check Access failsConfirm the token hasn’t expired, that it grants Contents: Read and Write on the exact repository entered, and that the repository URL or slug is spelled correctly. Note that Check Access only recognizes a token typed into the field during the current session — if you’re reopening the dialog to update just the repository or branch, you’ll need to re-enter the token as well before Check Access will re-enable.
Repository URL rejectedUse either a full HTTPS URL (https://github.com/org/repo) or an org/repo slug, with or without a trailing .git — other formats (like SSH URLs) aren’t accepted.
Export seems stuckLarger apps can take a few minutes to push. GitHub exports don’t appear on the Activity tab — check your repository’s commit history on the target branch to confirm the push completed.

Can I reconfigure the connection later? Yes — reopen the GitHub Export card from Publish Destinations at any time to update the repository, branch, or token. Note that Check Access only recognizes a token entered during that session, so if you’re only updating the repository or branch, you’ll need to re-enter the token as well to re-verify access.

Does this replace the ZIP export? No, they’re independent. Download Project gives you a one-time ZIP; GitHub Export pushes commits to a live repository each time you export.

What exactly gets exported? Your app’s generated source code — the same codebase you’d get from a manual ZIP export — pushed as a commit to the branch you configured, unless nothing has changed since your last export, in which case no new commit is created. Each export replaces the branch’s existing contents (aside from .git), so use a dedicated branch as described above.