Commit 997e9915 by Ivan

feat: 调整权限与部署

parent bc710a02
...@@ -37,7 +37,7 @@ export default function Edit({ image, tags, auth, errors = {} }) { ...@@ -37,7 +37,7 @@ export default function Edit({ image, tags, auth, errors = {} }) {
onSubmit={handleSubmit} onSubmit={handleSubmit}
submitButtonText="保存" submitButtonText="保存"
processingButtonText="保存中..." processingButtonText="保存中..."
showTagsField={true} showTagsField={auth.roles?.includes('admin')}
showStatusField={auth.roles?.includes('admin')} showStatusField={auth.roles?.includes('admin')}
isEdit={true} isEdit={true}
image={image} image={image}
......
...@@ -9,7 +9,7 @@ export default function Show({ image, auth }) { ...@@ -9,7 +9,7 @@ export default function Show({ image, auth }) {
<ComImageShow <ComImageShow
path={`/images/${image.id}`} path={`/images/${image.id}`}
image={image} image={image}
can_edit={auth.roles?.includes('admin')} can_edit={auth.roles?.includes('admin') || image.status === 'pending'}
can_approve={auth.roles?.includes('admin')} can_approve={auth.roles?.includes('admin')}
can_delete={auth.roles?.includes('admin')} can_delete={auth.roles?.includes('admin')}
isAdmin={auth.roles?.includes('admin')} isAdmin={auth.roles?.includes('admin')}
......
...@@ -38,25 +38,71 @@ sleep 5 ...@@ -38,25 +38,71 @@ sleep 5
if [ -z "${GIT_REPOSITORY}" ]; then if [ -z "${GIT_REPOSITORY}" ]; then
echo "⚠️ GIT_REPOSITORY environment variable not set. Using mounted code directory." echo "⚠️ GIT_REPOSITORY environment variable not set. Using mounted code directory."
else else
# 检查代码目录是否已经存在文件 # 检查代码目录是否为空或只包含隐藏文件
if [ "$(ls -A /rails/code 2>/dev/null)" ]; then if [ "$(find /rails/code -type f -not -path "*/\.*" | wc -l)" -gt 0 ]; then
echo "✅ Code directory is not empty. Using mounted code directory." echo "✅ Code directory contains non-hidden files. Checking Git repository status."
echo "Skipping Git operations to avoid permission issues."
# 检查是否是一个有效的Git仓库
if [ -d "/rails/code/.git" ]; then
echo "Git repository exists, attempting to pull latest changes..."
cd /rails/code
git config --global --add safe.directory /rails/code
git fetch || echo "Git fetch failed, but continuing anyway"
# Check if we need to checkout a specific branch or tag
if [ -n "${GIT_BRANCH}" ]; then
echo "Checking out branch/tag: ${GIT_BRANCH}"
git checkout ${GIT_BRANCH} || echo "Git checkout failed, but continuing anyway"
git pull origin ${GIT_BRANCH} || echo "Git pull failed, but continuing anyway"
else
echo "No branch specified, attempting to pull latest from current branch"
git pull || echo "Git pull failed, but continuing anyway"
fi
else
echo "⚠️ Code directory is not a Git repository. Attempting to clone repository..."
# 备份现有文件
echo "Backing up existing files..."
mkdir -p /tmp/code_backup
cp -r /rails/code/* /tmp/code_backup/ 2>/dev/null || true
# 清空目录并克隆仓库
echo "Cleaning directory and cloning repository..."
rm -rf /rails/code/* /rails/code/.[!.]* 2>/dev/null || true
# 尝试克隆仓库
if [ -n "${GIT_BRANCH}" ]; then
git clone --branch ${GIT_BRANCH} ${GIT_REPOSITORY} /rails/code || echo "Git clone failed, restoring backup"
else
git clone ${GIT_REPOSITORY} /rails/code || echo "Git clone failed, restoring backup"
fi
# 如果克隆失败,恢复备份
if [ ! -d "/rails/code/.git" ]; then
echo "Git clone failed, restoring backup files..."
cp -r /tmp/code_backup/* /rails/code/ 2>/dev/null || true
fi
# 清理备份
rm -rf /tmp/code_backup
fi
else else
echo "🔄 Setting up code from Git repository: ${GIT_REPOSITORY}" echo "🔄 Code directory is empty or contains only hidden files. Setting up from Git repository: ${GIT_REPOSITORY}"
# 添加 Git 安全目录配置,解决仓库所有权问题 # 添加 Git 安全目录配置,解决仓库所有权问题
echo "Configuring Git safe directory..." echo "Configuring Git safe directory..."
git config --global --add safe.directory /rails/code git config --global --add safe.directory /rails/code
# 清空目录以确保没有隐藏文件干扰
rm -rf /rails/code/* /rails/code/.[!.]* 2>/dev/null || true
# 检查是否安装了 git 命令 # 检查是否安装了 git 命令
if ! command -v git &> /dev/null; then if ! command -v git &> /dev/null; then
echo "⚠️ Git command not found. Skipping Git operations." echo "⚠️ Git command not found. Skipping Git operations."
else else
# 检查是否能访问 Git 仓库 # 检查是否能访问 Git 仓库
if git ls-remote --quiet ${GIT_REPOSITORY} &> /dev/null; then if git ls-remote --quiet ${GIT_REPOSITORY} &> /dev/null; then
# 尝试克隆仓库,但可能会失败 # 尝试克隆仓库
echo "Attempting to clone repository (may fail if directory is mounted)..." echo "Cloning repository..."
if [ -n "${GIT_BRANCH}" ]; then if [ -n "${GIT_BRANCH}" ]; then
git clone --branch ${GIT_BRANCH} ${GIT_REPOSITORY} /rails/code || echo "Git clone failed, but continuing anyway" git clone --branch ${GIT_BRANCH} ${GIT_REPOSITORY} /rails/code || echo "Git clone failed, but continuing anyway"
else else
...@@ -68,25 +114,7 @@ else ...@@ -68,25 +114,7 @@ else
fi fi
fi fi
# 如果存在 Git 仓库,尝试更新,但不强制 echo "✅ Using code from Git repository or mounted directory"
if [ -d "/rails/code/.git" ]; then
echo "Git repository exists, attempting to pull latest changes..."
cd /rails/code
git config --global --add safe.directory /rails/code
git fetch || echo "Git fetch failed, but continuing anyway"
# Check if we need to checkout a specific branch or tag
if [ -n "${GIT_BRANCH}" ]; then
echo "Checking out branch/tag: ${GIT_BRANCH}"
git checkout ${GIT_BRANCH} || echo "Git checkout failed, but continuing anyway"
git pull origin ${GIT_BRANCH} || echo "Git pull failed, but continuing anyway"
else
echo "No branch specified, attempting to pull latest from current branch"
git pull || echo "Git pull failed, but continuing anyway"
fi
fi
echo "✅ Using code from mounted directory"
fi fi
# Create symbolic links from code directory to Rails app directory # Create symbolic links from code directory to Rails app directory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment