Compare commits

..

No commits in common. "c96bef351523d7b3257e70b1f4acd153df740b39" and "ee7f3ffea35d63b799fa4d69b60a626f968e89aa" have entirely different histories.

7 changed files with 21 additions and 106 deletions

View File

@ -28,14 +28,12 @@ jobs:
password: ${{ secrets.SWR_PASSWORD }}
- name: Build and Push Backend
id: build
run: |
set -o pipefail
docker buildx build \
--push \
--provenance=false \
--tag ${{ secrets.SWR_SERVER }}/${{ secrets.SWR_ORG }}/rtc-backend:latest \
. 2>&1 | tee /tmp/build.log
uses: docker/build-push-action@v4
with:
context: .
push: true
provenance: false
tags: ${{ secrets.SWR_SERVER }}/${{ secrets.SWR_ORG }}/rtc-backend:latest
- name: Setup Kubectl
run: |
@ -50,7 +48,6 @@ jobs:
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Update K8s Manifests
id: deploy
run: |
# 1. 判断分支,决定使用哪个配置文件
if [[ "${{ github.ref_name }}" == "main" || "${{ github.ref_name }}" == "master" ]]; then
@ -68,62 +65,9 @@ jobs:
# 2. 替换镜像地址
sed -i "s|\${CI_REGISTRY_IMAGE}/backend:latest|${{ secrets.SWR_SERVER }}/${{ secrets.SWR_ORG }}/rtc-backend:latest|g" $DEPLOY_FILE
# 3. 应用配置并捕获输出
set -o pipefail
{
kubectl apply -f $DEPLOY_FILE
kubectl apply -f $INGRESS_FILE
kubectl rollout restart deployment/$DEPLOY_NAME
} 2>&1 | tee /tmp/deploy.log
# 3. 应用配置
# kubectl apply -f k8s/redis-deployment.yaml (Cloud Redis used, skipping)
kubectl apply -f $DEPLOY_FILE
kubectl apply -f $INGRESS_FILE
- name: Report failure to Log Center
if: failure()
run: |
# 收集构建和部署日志(取最后 50 行)
BUILD_LOG=""
DEPLOY_LOG=""
FAILED_STEP="unknown"
if [ -f /tmp/build.log ]; then
BUILD_LOG=$(tail -50 /tmp/build.log | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
FAILED_STEP="build"
fi
if [ -f /tmp/deploy.log ]; then
DEPLOY_LOG=$(tail -50 /tmp/deploy.log | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
if [ -n "$DEPLOY_LOG" ]; then
FAILED_STEP="deploy"
fi
fi
# 如果构建日志为空action 级别失败),标记步骤
if [ -z "$BUILD_LOG" ] && [ -z "$DEPLOY_LOG" ]; then
BUILD_LOG="No captured output. Check Gitea Actions UI for details."
FAILED_STEP="pre-build"
fi
ERROR_LOG="${BUILD_LOG}${DEPLOY_LOG}"
curl -s -X POST "https://qiyuan-log-center-api.airlabs.art/api/v1/logs/report" \
-H "Content-Type: application/json" \
-d "{
\"project_id\": \"rtc_backend\",
\"environment\": \"${{ github.ref_name }}\",
\"level\": \"ERROR\",
\"source\": \"cicd\",
\"commit_hash\": \"${{ github.sha }}\",
\"repo_url\": \"https://gitea.airlabs.art/zyc/rtc_backend.git\",
\"error\": {
\"type\": \"CICDFailure\",
\"message\": \"[${FAILED_STEP}] Build and Deploy failed on branch ${{ github.ref_name }}\",
\"stack_trace\": [\"${ERROR_LOG}\"]
},
\"context\": {
\"job_name\": \"build-and-deploy\",
\"step_name\": \"${FAILED_STEP}\",
\"workflow\": \"${{ github.workflow }}\",
\"run_id\": \"${{ github.run_id }}\",
\"branch\": \"${{ github.ref_name }}\",
\"actor\": \"${{ github.actor }}\",
\"commit\": \"${{ github.sha }}\"
}
}" || true
kubectl rollout restart deployment/$DEPLOY_NAME

View File

@ -204,12 +204,8 @@ class ShelfViewSet(viewsets.ViewSet):
except StoryShelf.DoesNotExist:
return error(code=ErrorCode.SHELF_NOT_FOUND, message='书架不存在')
with transaction.atomic():
try:
Story.objects.filter(shelf=shelf).update(shelf=None)
except Exception:
Story.objects.filter(shelf=shelf).delete()
shelf.delete()
Story.objects.filter(shelf=shelf).update(shelf=None)
shelf.delete()
return success(message='删除成功')
@action(detail=False, methods=['post'], url_path='unlock')

View File

@ -60,14 +60,6 @@ spec:
value: "LTAI5tBGAkR2rra2prTAX9yc"
- name: ALIYUN_LOG_ACCESS_KEY_SECRET
value: "U1z3d0p5saPRD5sCxVooJYSjxSAmKB"
# Log Center
- name: ENVIRONMENT
value: "development"
- name: LOG_CENTER_URL
value: "https://qiyuan-log-center-api.airlabs.art"
- name: LOG_CENTER_ENABLED
value: "true"
resources:
requests:
memory: "256Mi"

View File

@ -68,14 +68,6 @@ spec:
value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art"
- name: CSRF_TRUSTED_ORIGINS
value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art,https://qiyuan-rtc-api.airlabs.art"
# Log Center
- name: ENVIRONMENT
value: "production"
- name: LOG_CENTER_URL
value: "https://qiyuan-log-center-api.airlabs.art"
- name: LOG_CENTER_ENABLED
value: "true"
resources:
requests:
memory: "256Mi"

View File

@ -5,7 +5,7 @@ certifi==2026.1.4
cffi==2.0.0
charset-normalizer==3.4.4
crcmod==1.7
cryptography==44.0.3
cryptography==46.0.4
Django==6.0.1
django-cors-headers==4.9.0
djangorestframework==3.16.1
@ -27,14 +27,7 @@ six==1.17.0
sqlparse==0.5.5
urllib3==2.6.3
drf-spectacular==0.27.1
alibabacloud_dysmsapi20170525==4.4.0
alibabacloud_dypnsapi20170525==2.0.0
alibabacloud-tea-openapi==0.4.3
alibabacloud-tea-util==0.3.14
alibabacloud-credentials==1.0.2
alibabacloud-openapi-util==0.2.2
alibabacloud-gateway-spi==0.0.3
alibabacloud-endpoint-util==0.0.4
darabonba-core==1.0.5
alibabacloud_dysmsapi20170525>=4.4.0
alibabacloud_dypnsapi20170525>=3.0.0
volcengine-python-sdk[ark]>=5.0.9
edge-tts>=6.1.0

View File

@ -32,9 +32,8 @@ def report_to_log_center(exc, context):
payload = {
"project_id": "rtc_backend",
"environment": os.environ.get('ENVIRONMENT', 'development'),
"environment": os.environ.get('ENVIRONMENT', 'production'),
"level": "ERROR",
"repo_url": "https://gitea.airlabs.art/zyc/rtc_backend.git",
"error": {
"type": type(exc).__name__,
"message": str(exc),

View File

@ -47,9 +47,8 @@ def _report_exception(exc, request):
payload = {
"project_id": "rtc_backend",
"environment": os.environ.get('ENVIRONMENT', 'development'),
"environment": os.environ.get('ENVIRONMENT', 'production'),
"level": "ERROR",
"repo_url": "https://gitea.airlabs.art/zyc/rtc_backend.git",
"error": {
"type": type(exc).__name__,
"message": str(exc),