mirror of
https://github.com/schroinerxy/cloud-mail.git
synced 2026-06-21 19:35:50 +08:00
新增更多部署错误提示
This commit is contained in:
@@ -64,15 +64,34 @@ jobs:
|
|||||||
echo "🔐 Starting environment setup..."
|
echo "🔐 Starting environment setup..."
|
||||||
|
|
||||||
if [ -z "$JWT_SECRET" ] || grep -q '[?%#/\\]' <<< "$JWT_SECRET"; then
|
if [ -z "$JWT_SECRET" ] || grep -q '[?%#/\\]' <<< "$JWT_SECRET"; then
|
||||||
echo "❌ JWT_SECRET is empty or contains invalid characters (?, %, #, /, \\)"
|
echo "❌ JWT_SECRET variable is empty or contains invalid characters (?, %, #, /, \\)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! jq -e 'type == "array"' <<< "$DOMAIN" ; then
|
if ! jq -e 'type == "array"' <<< "$DOMAIN" ; then
|
||||||
echo "❌ DOMAIN must be a JSON array ([])."
|
echo "❌ DOMAIN variable must be a JSON array (e.g., [\"example.com\"])."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$ADMIN" ]; then
|
||||||
|
echo "❌ ADMIN variable cannot be empty."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then
|
||||||
|
echo "❌ CLOUDFLARE_ACCOUNT_ID variable cannot be empty."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
|
||||||
|
echo "❌ CLOUDFLARE_API_TOKEN variable cannot be empty."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CUSTOM_DOMAIN" ]; then
|
||||||
|
echo "::error:: CUSTOM_DOMAIN variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
CONFIG_FILE="wrangler-action.toml"
|
CONFIG_FILE="wrangler-action.toml"
|
||||||
|
|
||||||
if [ -z "$R2_BUCKET_NAME" ]; then
|
if [ -z "$R2_BUCKET_NAME" ]; then
|
||||||
@@ -165,7 +184,11 @@ jobs:
|
|||||||
echo "🚀 Starting deployment..."
|
echo "🚀 Starting deployment..."
|
||||||
pnpm wrangler deploy -c wrangler-action.toml | tee deploy.log | grep -v "https://.*\.workers\.dev" || true
|
pnpm wrangler deploy -c wrangler-action.toml | tee deploy.log | grep -v "https://.*\.workers\.dev" || true
|
||||||
WORKER_URL=$(grep -o "https://.*\.workers\.dev" deploy.log || echo "")
|
WORKER_URL=$(grep -o "https://.*\.workers\.dev" deploy.log || echo "")
|
||||||
echo "::add-mask::$WORKER_URL"
|
|
||||||
|
if [ -n "$WORKER_URL" ]; then
|
||||||
|
echo "::add-mask::$WORKER_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "worker_url=$WORKER_URL" >> $GITHUB_OUTPUT
|
echo "worker_url=$WORKER_URL" >> $GITHUB_OUTPUT
|
||||||
echo "✅ Setup completed."
|
echo "✅ Setup completed."
|
||||||
|
|
||||||
@@ -174,10 +197,11 @@ jobs:
|
|||||||
echo "🛠️ Starting database initialization..."
|
echo "🛠️ Starting database initialization..."
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|
||||||
WORKER_URL="${CUSTOM_DOMAIN:-${{ steps.deploy.outputs.worker_url }}}"
|
WORKER_URL="${CUSTOM_DOMAIN:+https://$CUSTOM_DOMAIN}"
|
||||||
|
WORKER_URL="${WORKER_URL:-${{ steps.deploy.outputs.worker_url }}}"
|
||||||
|
|
||||||
if [ -z "$WORKER_URL" ]; then
|
if [ -z "$WORKER_URL" ]; then
|
||||||
echo "❌ No URL available."
|
echo "❌ Preview URL not available. Please set CUSTOM_DOMAIN."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -196,7 +220,8 @@ jobs:
|
|||||||
|
|
||||||
echo "🛠️ Starting email receiving setup..."
|
echo "🛠️ Starting email receiving setup..."
|
||||||
|
|
||||||
WORKER_URL="${CUSTOM_DOMAIN:-${{ steps.deploy.outputs.worker_url }}}"
|
WORKER_URL="${CUSTOM_DOMAIN:+https://$CUSTOM_DOMAIN}"
|
||||||
|
WORKER_URL="${WORKER_URL:-${{ steps.deploy.outputs.worker_url }}}"
|
||||||
|
|
||||||
HTTP_CODE=$(curl -sL --post301 --post302 --post303 -w "%{http_code}" -o response.txt \
|
HTTP_CODE=$(curl -sL --post301 --post302 --post303 -w "%{http_code}" -o response.txt \
|
||||||
-X POST \
|
-X POST \
|
||||||
@@ -208,13 +233,16 @@ jobs:
|
|||||||
|
|
||||||
if [ "$RESPONSE_BODY" = "success" ]; then
|
if [ "$RESPONSE_BODY" = "success" ]; then
|
||||||
echo "✅ Setup completed."
|
echo "✅ Setup completed."
|
||||||
else
|
|
||||||
echo "::error:: Email receiving setup failed."
|
|
||||||
echo "HTTP status: $HTTP_CODE. Response:"
|
|
||||||
echo "$RESPONSE_BODY" | jq . 2>/dev/null || echo "$RESPONSE_BODY"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "200" ] && [ "$RESPONSE_BODY" != "success" ]; then
|
||||||
|
echo "::error:: Email receiving setup failed: $RESPONSE_BODY"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::error:: Email receiving setup failed: $HTTP_CODE $RESPONSE_BODY"
|
||||||
|
|
||||||
- name: 🗑️ 删除运行记录 / Delete workflow runs
|
- name: 🗑️ 删除运行记录 / Delete workflow runs
|
||||||
uses: GitRML/delete-workflow-runs@main
|
uses: GitRML/delete-workflow-runs@main
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ app.onError((err, c) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err.message === `Cannot read properties of undefined (reading 'get')`) {
|
if (err.message === `Cannot read properties of undefined (reading 'get')`) {
|
||||||
return c.json(result.fail('KV数据库未绑定<br>KV database not bound',502));
|
return c.json(result.fail('KV数据库未绑定 KV database not bound',502));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.message === `Cannot read properties of undefined (reading 'put')`) {
|
if (err.message === `Cannot read properties of undefined (reading 'put')`) {
|
||||||
return c.json(result.fail('KV数据库未绑定<br>KV database not bound',502));
|
return c.json(result.fail('KV数据库未绑定 KV database not bound',502));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.message === `Cannot read properties of undefined (reading 'prepare')`) {
|
if (err.message === `Cannot read properties of undefined (reading 'prepare')`) {
|
||||||
return c.json(result.fail('D1数据库未绑定<br>D1 database not bound',502));
|
return c.json(result.fail('D1数据库未绑定 D1 database not bound',502));
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.json(result.fail(err.message, err.code));
|
return c.json(result.fail(err.message, err.code));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export async function initForward(c, params) {
|
|||||||
mainList = [...new Set(mainList)];
|
mainList = [...new Set(mainList)];
|
||||||
|
|
||||||
if (mainList.length === 0) {
|
if (mainList.length === 0) {
|
||||||
return c.text('Domain does not exist.');
|
return c.text('DOMAIN does not exist in Cloudflare.');
|
||||||
}
|
}
|
||||||
|
|
||||||
//开启主域名电子邮件路由
|
//开启主域名电子邮件路由
|
||||||
@@ -62,9 +62,9 @@ export async function initForward(c, params) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
const error = body.errors[0];
|
||||||
if(!res.ok) {
|
if(!res.ok) {
|
||||||
return c.json(body);
|
return c.text(`${error.code} ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -93,9 +93,9 @@ export async function initForward(c, params) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
const error = body.errors[0];
|
||||||
if(!res.ok) {
|
if(!res.ok) {
|
||||||
return c.json(body);
|
return c.text(`${error.code} ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -112,9 +112,9 @@ export async function initForward(c, params) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
const error = body.errors[0];
|
||||||
if(!res.ok) {
|
if(!res.ok) {
|
||||||
return c.json(body);
|
return c.text(`${error.code} ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ const settingService = {
|
|||||||
|
|
||||||
const setting = await c.env.kv.get(KvConst.SETTING, { type: 'json' });
|
const setting = await c.env.kv.get(KvConst.SETTING, { type: 'json' });
|
||||||
|
|
||||||
|
if (!setting) {
|
||||||
|
throw new BizError('数据库未初始化 Database not initialized.');
|
||||||
|
}
|
||||||
|
|
||||||
let domainList = c.env.domain;
|
let domainList = c.env.domain;
|
||||||
|
|
||||||
if (typeof domainList === 'string') {
|
if (typeof domainList === 'string') {
|
||||||
|
|||||||
Reference in New Issue
Block a user