Add CI/CD build and deploy scripts, along with docker-compose, HAProxy config, and a certbot
Some checks failed
Build And Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build And Deploy / build-and-deploy (push) Has been cancelled
merge hook. Set up env.example generation. Add doiuse dev dependency.
This commit is contained in:
parent
0350a4b8e3
commit
1714225d00
11 changed files with 334 additions and 2 deletions
47
utils/generate-env-example.sh
Executable file
47
utils/generate-env-example.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd $(dirname $(dirname $(realpath $0)))
|
||||
|
||||
# Path to the original .env file
|
||||
ENV_FILE=".env"
|
||||
# Path to the new .env.example file
|
||||
EXAMPLE_FILE=".env.example"
|
||||
|
||||
# Check if the .env file exists
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "The file $ENV_FILE does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create or empty the .env.example file
|
||||
> "$EXAMPLE_FILE"
|
||||
|
||||
SKIP_NEXT=false
|
||||
|
||||
# Read each line in .env
|
||||
while IFS= read -r line; do
|
||||
# Skip the current line if the previous line is part of a multiline/quoted string
|
||||
if [[ $SKIP_NEXT == true ]]; then
|
||||
if [[ $line == *'"'* ]]; then
|
||||
SKIP_NEXT=false
|
||||
fi
|
||||
continue
|
||||
# Copy comments and empty lines verbatim
|
||||
elif [[ $line == \#* ]] || [[ -z $line ]]; then
|
||||
echo "$line" >> "$EXAMPLE_FILE"
|
||||
continue
|
||||
# Check if the line is a multiline/quoted string
|
||||
elif [[ $line == *'="'* ]]; then
|
||||
if [[ $line != *'"' ]]; then
|
||||
SKIP_NEXT=true
|
||||
fi
|
||||
LINE=${line%%=*}
|
||||
echo "$LINE=\"\${$LINE}\"" >> "$EXAMPLE_FILE"
|
||||
# For all other lines, copy only the key (everything before the '=') if present
|
||||
elif [[ $line == *'='* ]]; then
|
||||
LINE=${line%%=*}
|
||||
echo "$LINE=\${$LINE}" >> "$EXAMPLE_FILE"
|
||||
fi
|
||||
done < "$ENV_FILE"
|
||||
|
||||
echo ".env.example file created successfully."
|
||||
Loading…
Add table
Add a link
Reference in a new issue