Skip to content

deploy-github

将本地目录部署到 GitHub Pages。

CLI 用法

bash
npx t-comm deploy:github [options]

选项

选项说明
--repo <repo>GitHub 仓库名称
--user <user>GitHub 用户名
--email <email>登录邮箱
--dir <dir>要部署的本地目录
--token <token>GitHub Token
--branch <branch>目标分支
--message <message>提交信息
--increment <increment>是否增量部署(1 为增量)
--playgroundDir <playgroundDir>Playground 目录(增量模式必填)
--targetDirName <targetDirName>目标目录名称(增量模式必填)

环境变量

所有选项均可通过环境变量配置(在 .env.local 文件中设置):

环境变量对应选项
DEPLOY_GITHUB_PAGE_REPO_NAME--repo
DEPLOY_GITHUB_PAGE_USER_NAME--user
DEPLOY_GITHUB_PAGE_EMAIL--email
DEPLOY_GITHUB_PAGE_TARGET_DIR--dir
DEPLOY_GITHUB_PAGE_TOKEN--token
DEPLOY_GITHUB_PAGE_BRANCH--branch
DEPLOY_GITHUB_PAGE_COMMIT_MESSAGE--message
DEPLOY_GITHUB_PAGE_COMMIT_INCREMENT--increment
DEPLOY_GITHUB_PAGE_PLAYGROUND_DIR--playgroundDir
DEPLOY_GITHUB_PAGE_TARGE_DIR_NAME--targetDirName

示例

bash
# 全量部署
npx t-comm deploy:github \
  --repo my-project \
  --user myname \
  --email myname@example.com \
  --dir docs/.vitepress/dist \
  --token ghp_xxxx \
  --branch gh-pages \
  --message "deploy: update docs"

# 增量部署
npx t-comm deploy:github \
  --repo my-project \
  --user myname \
  --email myname@example.com \
  --dir docs/.vitepress/dist \
  --token ghp_xxxx \
  --branch gh-pages \
  --increment 1 \
  --playgroundDir ./playground \
  --targetDirName demo

注意事项

  1. 命令行参数优先级高于环境变量
  2. 增量模式下 --playgroundDir--targetDirName 为必填
  3. 支持通过 .env.local 文件管理敏感信息(如 Token)