- When you create a repo with
baseRepo, Code Storage links it to the specified GitHub repository - The
pullUpstream()method fetches the latest changes from GitHub - You can then use all SDK features (diffs, commits, file access) on the synced content
- The provider is automatically set to “github” when using
baseRepo
Note: GitHub-backed repositories treat GitHub as the source of truth. This means all pushes to Code Storage are forwarded to GitHub and all changes are mirrored back to Code Storage.
Setup GitHub App
To enable GitHub sync, you’ll need to create a GitHub App:1
Create the app
- Go to Settings → Developer settings → GitHub Apps
2
Set permissions
Repository permissions:
- Contents: Read
- Metadata: Read
- Push
- Create
- Pull Request (optional, if you want PR sync)
- Let Code Storage handle callbacks for you:
- Or use your own handler
3
Record credentials
- GitHub App ID
- Private Key
- Webhook Secret
Automatic Sync with Webhooks
Your GitHub App can emit webhook events to automatically sync changes. You can either handle them yourself or let Code Storage manage them. Option A: Handle Webhooks Yourself If you already have a webhook handler or want more control:- Set the Webhook callback URL to point to your handler.
- Your handler should process GitHub events and call Code Storage as needed.
Note: Use repo.pullUpstream() to trigger a sync from GitHub when handling events manually.
For more on webhook verification and validation, see Webhooks.
Option B: Let Code Storage Handle Webhooks
If you don’t want to run your own webhook handler:
- In your GitHub App settings, set the webhook URL to:
https://[your-organization].code.storage/webhook/github - Generate a webhook secret and save it.
- In the Code Storage dashboard → Integrations tab, enter your secret and save.