File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -172,14 +172,27 @@ jobs:
172172 script : |
173173 set -eu
174174 cd "$DEPLOY_PATH"
175+ ENV_FILE="./deploy/env/backend.env"
175176
176- if [ ! -f "./deploy/env/backend.env " ]; then
177- echo "Missing required file: ./deploy/env/backend.env "
177+ if [ ! -f "$ENV_FILE " ]; then
178+ echo "Missing required file: $ENV_FILE "
178179 exit 1
179180 fi
180181
182+ # Load backend env even when file is owned by root (e.g. mode 600).
181183 set -a
182- . ./deploy/env/backend.env
184+ TMP_ENV="$(mktemp)"
185+ if [ -r "$ENV_FILE" ]; then
186+ cat "$ENV_FILE" > "$TMP_ENV"
187+ else
188+ echo "No read permission for $ENV_FILE, loading via sudo..."
189+ sudo cat "$ENV_FILE" > "$TMP_ENV"
190+ fi
191+
192+ # Normalize potential CRLF and source variables
193+ sed -i 's/\r$//' "$TMP_ENV"
194+ . "$TMP_ENV"
195+ rm -f "$TMP_ENV"
183196 set +a
184197
185198 : "${DB_USERNAME:=smalltrend}"
You can’t perform that action at this time.
0 commit comments