本项目使用 Satis 搭建私有 Composer 包仓库,支持:
- ✅ 托管私有 PHP 包
- ⚡ 镜像加速公共包
- 📦 离线包缓存
- 🔒 安全访问 Git 私有仓库
在项目 composer.json
中添加:
{
"repositories": [
{
"type": "composer",
"url": "https://yourname.github.io/composer"
}
]
}
ssh-keygen -t ed25519 -C "codeup-deploy@yourcompany.com" -f codeup-deploy-key
- 复制公钥内容:
cat codeup-deploy-key.pub
- 登录 Codeup → 项目设置 → 部署密钥 → 添加公钥
- 进入仓库 Settings → Secrets → Actions
- 添加新 secret:
- 名称:
CODEUP_SSH_KEY
- 值:粘贴
codeup-deploy-key
文件内容
- 名称:
{
"name": "your-repo-name",
"repositories": [
{
"type": "git",
"url": "git@codeup.aliyun.com:your-group/your-repo.git"
}
],
"require": {
"your-group/your-repo": "*"
}
}
本仓库使用 GitHub Actions 自动构建,主要流程:
-
配置 SSH 访问:
- 加载存储在 Secrets 的 SSH 私钥
- 添加 Codeup 到 known_hosts
- 测试连接
-
构建环境准备:
- 缓存 Composer 依赖
- 安装 PHP 和指定工具
- 安装 Satis 工具
-
仓库构建:
- 根据 satis.json 构建仓库
- 缓存构建结果
-
发布到 GitHub Pages
- 修改 satis.json 或添加新包
- 推送更改到 main 分支
- 自动触发 GitHub Actions 工作流
构建完成后,访问:
https://yourname.github.io/composer
在 GitHub Actions 日志中查看 "测试连接" 步骤的输出,应显示:
Welcome to Codeup, your_username!
- 检查 Actions 运行日志
- 验证 SSH 密钥是否正确配置
- 确认 satis.json 格式正确
- 在私有仓库发布新版本
- 推送更改到 main 分支触发自动构建
- 客户端运行
composer update