diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index bff4cbc..fe2a479 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -29,27 +29,37 @@ jobs: DB_HOSTNAME: ${{ env.DB_HOSTNAME }} run: | set -euo pipefail - cp .example.env .env + if [ ! -f .env ]; then + cp .example.env .env - awk -v host="$DB_HOSTNAME" -v newpwd="$MYSQL_PASSWORD" ' - BEGIN { has_host = 0; has_pwd = 0 } - $0 ~ /^HOSTNAME=/ { - print "HOSTNAME=" host - has_host = 1 - next - } - $0 ~ /^PASSWORD=/ { - print "PASSWORD=" newpwd - has_pwd = 1 - next - } - { print } - END { - if (!has_host) print "HOSTNAME=" host - if (!has_pwd) print "PASSWORD=" newpwd - }' .env > .env.tmp + awk -v host="$DB_HOSTNAME" -v newpwd="$MYSQL_PASSWORD" ' + BEGIN { has_host = 0; has_pwd = 0; has_demo = 0 } + $0 ~ /^HOSTNAME=/ { + print "HOSTNAME=" host + has_host = 1 + next + } + $0 ~ /^PASSWORD=/ { + print "PASSWORD=" newpwd + has_pwd = 1 + next + } + $0 ~ /^IS_DEMO=/ { + print "IS_DEMO=true" + has_demo = 1 + next + } + { print } + END { + if (!has_host) print "HOSTNAME=" host + if (!has_pwd) print "PASSWORD=" newpwd + if (!has_demo) print "IS_DEMO=true" + }' .env > .env.tmp - mv .env.tmp .env + mv .env.tmp .env + else + echo ".env exists in repository, skip generating/replacing." + fi - name: 打包发布文件 shell: bash