github - 如何防止对 main 的提交部署在 vercel 上
问题描述
我想知道是否有办法阻止 Vercel 部署直接提交以自动部署到生产环境。我不介意每次都必须单击一个额外的按钮——这可能吗?我看到了Ignored Build Step文档,但我真的不明白如何使用它,或者它是否是正确的使用方法。
解决方案
如果要使用 Ignored Build Step 功能,请执行以下操作
- 在您的存储库中创建一个
script.sh
文件:
#!/bin/bash
if [[ "$VERCEL_GIT_COMMIT_REF" == "main" ]] ; then
# Don't build
echo " - Build cancelled"
exit 0;
else
# Proceed with the build
echo "✅ - Build can proceed"
exit 1;
fi
在您的 Vercel Dashboard 中,转到您的项目设置 > Git > Ignored Build Step,并在字段中写入 <code>bash script.sh。
推荐阅读
- python - 如何在 python 3.7 中使用子进程读取 Windows 命令“查询用户”响应
- r - mutate 可以使用哪些类型的函数?
- c# - 我如何使用数据类型 IPHostEntry,包括嵌套 try-catch 之间的 while-loop?
- python - 通过迭代行来创建新的循环因变量
- python - 在 TensorFlow Probability 中,与贝叶斯层的损失属性相关的损失是什么?
- javascript - THREE.js 从 3D 矢量转换为 2D 像素位置,解释 z 坐标
- xpath - Google 表格 IMPORTXML 查询
- arrays - 如何在 Swift 中访问包含可变大小数组的 C 结构?
- java - 如何使约束布局的宽度为负?
- javascript - 将裁剪区域与非裁剪区域分开