GitHub Integration
GitHub App Architecture
Sitepins uses a GitHub App for secure, fine-grained repository access:
-
Installation Flow:
- User installs GitHub App on repositories
- App receives installation webhook
- Installation data stored in backend
-
Authentication Strategy:
- App-level authentication for repository operations
- User-level authentication for personal data
- JWT tokens for API requests
-
Permission Model:
- Contents: Read & Write (for file operations)
- Metadata: Read (for repository information)
- Pull Requests: Read & Write (for collaboration)
Content Management Workflow
- File Tree Retrieval:
// Fetch repository structure
const { data: trees } = useGetTreesQuery({
owner: "username",
repo: "repository",
tree_sha: "main",
recursive: "1",
});- Content Reading:
// Get file content with frontmatter parsing
const { data: content } = useGetContentQuery({
owner: "username",
repo: "repository",
path: "content/blog/post.md",
ref: "main",
parser: true,
});- Content Writing:
// Update files with Git workflow
const [updateFiles] = useUpdateFilesMutation();
await updateFiles({
owner: "username",
repo: "repository",
tree: "main",
files: [
{
path: "content/blog/new-post.md",
content: "---\ntitle: New Post\n---\n\nContent here...",
},
],
message: "Add new blog post",
});Git Operations
The system implements a complete Git workflow:
- Blob Creation: Convert file content to Git blobs
- Tree Construction: Organize blobs into directory structure
- Commit Creation: Create commit with proper attribution
- Reference Update: Update branch to point to new commit
Intelligent Features
- Legacy Migration: Automatically migrates old folder structures
- Configuration Detection: Finds and loads site configuration
- Framework Recognition: Detects Next.js, Astro, Hugo, etc.
- Media Handling: Special processing for binary files
Last updated on