昨天,在提交新文触发 Vercel 部署时,GitHub Action 报错,导致 CI 失败。而就在前一天,还一切正常。并且,我们也没有对 CI 和 Vercel 进行任何配置变更。
我们的环境:
- GitHub 免费公开组织下的私有仓库
- Vercel Hobby Plan
问题描述
GitHub Action 页面的报错如下:
Error: Git author **** must have access to the team ***'s projects on Vercel to create deployments.
Learn more: https://vercel.com/docs/deployments/troubleshoot-project-collaboration
很明显,报错信息提示我们 Git 提交者没有权限访问 Vercel 项目。查阅上述链接之后,发现:
The Hobby Plan does not support collaboration for private repositories. If you need collaboration, upgrade to the Pro Plan.
阔是,之前一直是好的呀!这只能说明 Vercel 最近对 Hobby Plan 的权限做了调整。但是,我们既不想现在升级,也不想改动现有的仓库类型。于是,打算在此前提之下先去找找解决方案。
解决方案
阶段 1:设置你的本地仓库 Git 用户名和邮箱
稍微用了一下搜索引擎,Google 的 AI Overview 就给出了正确的建议:
Confirm that the user.name and user.email configured in your local Git environment (e.g., using git config —global user.name “Your Name” and git config —global user.email “your.email@example.com”) match the name and email associated with the Vercel account that owns the Hobby team.
亲测有效!
阶段 2:修改 CI,发布前自动修改 Git 用户名和邮箱
以上方法是最简单的,除了修改一下 git 本地配置,无需任何改动。但是,代价是:从此之后,所有的提交都会是一个固定的用户!那有没有既保留原有的提交用户,又能让 Vercel 识别的方案呢?
当然有!
我们大可在 ci 中发布前修改一下 git 的用户和邮箱:
- name: Configure git identity for Vercel compatibility
run: |
git config user.name "your-vercel-username"
git config user.email "your-vercel-account-email"
git commit --amend --no-edit --author="your-vercel-username <your-vercel-account-email>"
echo "✅ Updated commit identity for Vercel compatibility"
这样,既保留了原有的提交用户,又能让 Vercel 识别。
亲测有效!