1.0.0 โ€ข Published 7 months ago

@kobonostudio/vite-plugin-github-deploy v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

๐Ÿš€ vite-plugin-github-deploy

A Vite plugin to automate GitHub deployment using git, gh CLI, and @octokit/rest. Perfect for JAMStack, Webflow, or static sites needing CDN-ready delivery.


โœจ Features

  • ๐Ÿ” SSH support + GitHub authentication (gh auth login)
  • ๐Ÿ“ Pushes either:
    • entire project (source + dist)
    • or dist/ only
  • ๐Ÿง  Smart detection of existing repositories
  • ๐Ÿ”„ Automatically creates repos via GitHub API (@octokit/rest)
  • ๐Ÿงฐ Works with starter.config.js for unified setup

โš™๏ธ Supported Deployment Modes

ModeDescription
noneSkips deployment entirely
public-onlyPushes full project (source + dist/) to a public repo
splitPushes source code to private repo, dist/ folder to public repo

Each mode fits a different use case:

  • public-only: For simple public open-source projects.
  • split: When your code is private but output must be public (e.g. CDN via jsDelivr).
  • none: When you want to manage deployment manually.

๐Ÿ“ฆ Installation

npm install --save-dev @kobonostudio/vite-plugin-github-deploy

๐Ÿ”ง Configuration (starter.config.js)

At your project root, create:

export default {
  cdn: {
    baseUrl: 'https://cdn.jsdelivr.net/gh',
    user: 'your-github-username-or-org',
    repo: 'your-public-repo',
    branch: 'main',
    org: true, // optional (true if you're using a GitHub org)
  },
  deploy: {
    mode: 'split', // 'none' | 'public-only' | 'split'
    publicRepo: 'webflow-assets',
    privateRepo: 'webflow-source',
    branch: 'main',
  },
}

๐Ÿ”Œ Usage in vite.config.js

import { defineConfig } from 'vite'
import githubDeployPlugin from '@kobonostudio/vite-plugin-github-deploy'

export default defineConfig({
  plugins: [githubDeployPlugin()],
})

๐Ÿš€ Trigger Deployment

Before deploying, you must manually build your project (e.g. with npm run build or npm run build:pages):

npm run build
#or
npm run build:pages

Then trigger deployment using the DEPLOY flag:

DEPLOY=true npm run build

This will:

  1. โœ… Verify git and gh are installed
  2. ๐Ÿ” Ensure SSH key exists and is configured
  3. ๐Ÿค Authenticate with GitHub CLI
  4. ๐Ÿ“ Create or detect GitHub repos
  5. ๐Ÿš€ Push files to correct repos based on deployment mode

๐Ÿงช Examples

โžค public-only

  • Project pushed entirely to git@github.com:user/project.git
  • Ideal for public showcase or open source

โžค split

  • dist/ โ†’ public repo (user/cdn-repo)
  • Source โ†’ private repo (user/source-repo)
  • Perfect for Webflow CDN or static assets

๐Ÿ“ What gets pushed?

FolderModeRepo type
. (all)public-onlyPublic
dist/splitPublic
. (all)splitPrivate

๐Ÿ›  Requirements

  • Node.js โ‰ฅ 18
  • git installed
  • gh GitHub CLI (gh auth login required)
  • SSH key (id_ed25519) added to GitHub
  • Internet access

๐Ÿง  Author

Made with โค๏ธ by Pierre Lovenfosse

๐Ÿ“„ License

MIT โ€” ยฉ Pierre Lovenfosse

1.0.0

7 months ago