mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 11:32:48 +08:00
ci: 在部署流程中默认关闭应用和数据库调试模式
All checks were successful
build-and-deploy / 直传代码并部署到 Host15 (push) Successful in 1m29s
All checks were successful
build-and-deploy / 直传代码并部署到 Host15 (push) Successful in 1m29s
添加 APP_DEBUG_VALUE 和 DB_DEBUG_VALUE 环境变量,并将其默认值设为 "false"。更新 awk 脚本以在生成 .env 配置文件时自动设置 APP_DEBUG 和 DEBUG 变量,确保生产部署时调试功能被禁用。
This commit is contained in:
@@ -9,6 +9,8 @@ env:
|
|||||||
PACKAGE_NAME: ulthon_admin_release.tar.gz
|
PACKAGE_NAME: ulthon_admin_release.tar.gz
|
||||||
COMPOSE_PROJECT_NAME: ulthon_admin
|
COMPOSE_PROJECT_NAME: ulthon_admin
|
||||||
DB_HOSTNAME: host.docker.internal
|
DB_HOSTNAME: host.docker.internal
|
||||||
|
APP_DEBUG_VALUE: "false"
|
||||||
|
DB_DEBUG_VALUE: "false"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy_host15:
|
deploy_host15:
|
||||||
@@ -27,12 +29,14 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
|
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
|
||||||
DB_HOSTNAME: ${{ env.DB_HOSTNAME }}
|
DB_HOSTNAME: ${{ env.DB_HOSTNAME }}
|
||||||
|
APP_DEBUG_VALUE: ${{ env.APP_DEBUG_VALUE }}
|
||||||
|
DB_DEBUG_VALUE: ${{ env.DB_DEBUG_VALUE }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cp .example.env .env
|
cp .example.env .env
|
||||||
|
|
||||||
awk -v host="$DB_HOSTNAME" -v newpwd="$MYSQL_PASSWORD" '
|
awk -v host="$DB_HOSTNAME" -v newpwd="$MYSQL_PASSWORD" -v app_debug="$APP_DEBUG_VALUE" -v db_debug="$DB_DEBUG_VALUE" '
|
||||||
BEGIN { has_host = 0; has_pwd = 0 }
|
BEGIN { has_host = 0; has_pwd = 0; has_app_debug = 0; has_db_debug = 0 }
|
||||||
$0 ~ /^HOSTNAME=/ {
|
$0 ~ /^HOSTNAME=/ {
|
||||||
print "HOSTNAME=" host
|
print "HOSTNAME=" host
|
||||||
has_host = 1
|
has_host = 1
|
||||||
@@ -43,10 +47,22 @@ jobs:
|
|||||||
has_pwd = 1
|
has_pwd = 1
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
$0 ~ /^APP_DEBUG=/ {
|
||||||
|
print "APP_DEBUG=" app_debug
|
||||||
|
has_app_debug = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
$0 ~ /^DEBUG=/ {
|
||||||
|
print "DEBUG=" db_debug
|
||||||
|
has_db_debug = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
{ print }
|
{ print }
|
||||||
END {
|
END {
|
||||||
if (!has_host) print "HOSTNAME=" host
|
if (!has_host) print "HOSTNAME=" host
|
||||||
if (!has_pwd) print "PASSWORD=" newpwd
|
if (!has_pwd) print "PASSWORD=" newpwd
|
||||||
|
if (!has_app_debug) print "APP_DEBUG=" app_debug
|
||||||
|
if (!has_db_debug) print "DEBUG=" db_debug
|
||||||
}' .env > .env.tmp
|
}' .env > .env.tmp
|
||||||
|
|
||||||
mv .env.tmp .env
|
mv .env.tmp .env
|
||||||
|
|||||||
Reference in New Issue
Block a user