update @native
Some checks failed
Setup Docker Action / setup_docker (3.12.7) (push) Has been skipped
Setup Native Action / setup_native (3.12.7) (push) Failing after 1m30s

This commit is contained in:
hoangvv 2025-01-15 10:56:59 +07:00
parent 7b42b514d0
commit 8f4fde6105
2 changed files with 8 additions and 8 deletions

View File

@ -10,8 +10,8 @@ jobs:
if: contains(github.event.head_commit.message, '@native')
runs-on: ubuntu-latest
env:
PG_USER: ${{ secrets.PG_USER }}
PG_PASSWORD: ${{ secrets.PG_PASSWORD }}
DB_USER: ${{ secrets.PG_USER }}
DB_PASSWORD: ${{ secrets.PG_PASSWORD }}
DB_SERVER: ${{ vars.DB_SERVER }}
DB_PORT: ${{ vars.DB_PORT }}
strategy:

View File

@ -8,7 +8,7 @@ SETUP_PATH=$(pwd)/setup
PIP=$(pwd)/venv/bin/pip
PYTHON=$(pwd)/venv/bin/python
PG_USER=nexterp
DB_USER=nexterp
ODOO_ADDONS=./addons
ODOO_CONFIG=./etc
# System
@ -186,7 +186,7 @@ Generate_Config_Docker(){
if [[ ! -f "${DEPLOY_PATH}/.env" ]]; then
cp "${DEPLOY_PATH}/env.template" "${DEPLOY_PATH}/.env"
fi
${PYTHON} "$SETUP_PATH/gen_config_docker.py" --db_port 5432 --db_user $PG_USER --deploy_path "$DEPLOY_PATH" \
${PYTHON} "$SETUP_PATH/gen_config_docker.py" --db_port 5432 --db_user $DB_USER --deploy_path "$DEPLOY_PATH" \
--image "${ODOO_IMAGE}" --container "${ODOO_CONTAINER}" --tag "${ODOO_TAG:=latest}" \
--addons "${ODOO_ADDONS}" --config "${ODOO_CONFIG}" --backup "${VERSION}"
Show 0 " Generate Config Complete"
@ -200,18 +200,18 @@ Generate_Config_Native(){
USER="${REPO_NAME:-"default_repo"}"
PASSWORD="$(openssl rand -hex 24)"
# Check if the user already exists
USER_EXISTS=$(psql "postgresql://${PG_USER}:${PG_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "SELECT 1 FROM pg_roles WHERE rolname='$USER';")
USER_EXISTS=$(psql "postgresql://${DB_USER}:${DB_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "SELECT 1 FROM pg_roles WHERE rolname='$USER';")
if [ -z "$USER_EXISTS" ]; then
# User does not exist, create the user
Show 2 "Create the new PostgreSQL username: $USER with password: $PASSWORD"
psql "postgresql://${PG_USER}:${PG_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "CREATE USER $USER WITH PASSWORD '$PASSWORD';"
psql "postgresql://${DB_USER}:${DB_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "CREATE USER $USER WITH PASSWORD '$PASSWORD';"
Show 2 " Grant $USER superuser (admin) privileges"
psql "postgresql://${PG_USER}:${PG_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "ALTER USER $USER WITH SUPERUSER;"
psql "postgresql://${DB_USER}:${DB_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "ALTER USER $USER WITH SUPERUSER;"
else
# User exists, update the password
Show 2 "User $USER already exists, updating password to $PASSWORD"
psql "postgresql://${PG_USER}:${PG_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "ALTER USER $USER WITH PASSWORD '$PASSWORD';"
psql "postgresql://${DB_USER}:${DB_PASSWORD}@${DB_SERVER}:${DB_PORT}/postgres" -c "ALTER USER $USER WITH PASSWORD '$PASSWORD';"
fi
${PYTHON} "$SETUP_PATH/gen_config.py" --db_user $USER --db_pass $PASSWORD --deploy_path "$(pwd)" \
--addons_path $ADDONS --db_port $DB_PORT