update makefile and workflow
All checks were successful
Setup Docker Action / setup_docker (3.12.7) (push) Successful in 51s

This commit is contained in:
hoangvv 2025-01-14 15:47:12 +07:00
parent 92a8c39b3d
commit be1ffd9aac
3 changed files with 20 additions and 8 deletions

View File

@ -38,6 +38,7 @@ jobs:
- name: Install dotenv
run: pip install python-dotenv
- name: Update Tag
run: make update_tag CURR_BRANCH=${{ github.ref_name }}
@ -59,12 +60,16 @@ jobs:
run: make restore_database
- name: Run Tests
if: contains(github.event.head_commit.message, '@run_test')
run: make run_test_docker
- name: Login Docker hub
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin ${{ secrets.DOCKER_HUB }}
- name: Push Image
if: contains(github.event.head_commit.message, '@push_image')
run: make push_image
- name: Logout Docker hub
run: docker logout ${{ secrets.DOCKER_HUB }}
- name: Clean Up
if: "!contains(github.event.head_commit.message, '@no_cleanup')"
run: make clean_up

View File

@ -8,22 +8,28 @@ DOCKER_COMPOSE_CMD=docker-compose
DOCKER_BUILD=$(DOCKERCMD) build
DOCKER_PUSH=$(DOCKERCMD) push
DOCKER_IMAGE=$(DOCKERCMD) image
DOCKER_EXEC=$(DOCKERCMD) exec
DEPLOY_PATH=${PWD}/deployment
SETUP_PATH=${PWD}/setup
CONFIG=odoo.conf
ODOO_IMAGE=hub.nextzenos.com/nexterp/odoo
DOCKER_SERVER=hub.nextzenos.com
ORGANIZATION=nexterp
PROJECT=$(shell git remote get-url origin | sed 's/.*\/\([^\/]*\)\.git$/\1/' || echo "odoo")
ODOO_IMAGE=${DOCKER_SERVER}/${ORGANIZATION}/$(PROJECT)
TAG := $(shell rev-parse --abbrev-ref HEAD)
CONTAINER_ID=odoo-${TAG}
CONTAINER_ID=${PROJECT}-${TAG}
VERSION := community
install:
sudo apt -y update && \
sudo apt install -y build-essential python3-full python3-pip libldap2-dev libpq-dev libsasl2-dev
sudo apt install -y build-essential python3-full python3-pip libldap2-dev libpq-dev libsasl2-dev && \
pip install -r requirements.txt
run_test_docker:
sudo docker exec ${CONTAINER_ID} odoo --test-tags :TestAccountMove.test_out_invoice_auto_post_monthly,TestAccountMove.test_included_tax --log-level=test --test-enable -d testdb --stop-after-init --config=/etc/odoo/${CONFIG} --xmlrpc-port=8071 && \
sudo docker exec ${CONTAINER_ID} odoo db --config=/etc/odoo/${CONFIG} drop testdb
sudo ${DOCKER_EXEC} ${CONTAINER_ID} odoo --test-tags :TestAccountMove.test_out_invoice_auto_post_monthly,TestAccountMove.test_included_tax --log-level=test --test-enable -d testdb --stop-after-init --config=/etc/odoo/${CONFIG} --xmlrpc-port=8071 && \
sudo ${DOCKER_EXEC} ${CONTAINER_ID} odoo db --config=/etc/odoo/${CONFIG} drop testdb
run_test_local:
odoo-bin -i all_modules --log-level=test --test-enable -d testdb --stop-after-init --config=${CONFIG}
gen_config:
${PWD}/setup/init_config.sh ${ODOO_IMAGE} ${TAG} ${CONTAINER_ID}
${PWD}/setup/init_config.sh ${ODOO_IMAGE} ${TAG} ${CONTAINER_ID} ${VERSION}
build_image:
DOCKER_BUILDKIT=1 ${DOCKER_BUILD} . --progress plain --tag ${ODOO_IMAGE}:${TAG}
push_image:

View File

@ -8,6 +8,7 @@ SETUP_PATH=$(pwd)/setup
ODOO_IMAGE=$1
ODOO_TAG=$2
ODOO_CONTAINER=$3
VERSION=$4
PG_USER=nexterp
ODOO_ADDONS=./addons
ODOO_CONFIG=./etc
@ -92,7 +93,7 @@ Generate_Config(){
fi
python "$SETUP_PATH/gen-config.py" --db_port 5432 --db_user $PG_USER --deploy_path "$DEPLOY_PATH" \
--image "${ODOO_IMAGE}" --container "${ODOO_CONTAINER}" --tag "${ODOO_TAG:=latest}" \
--addons "${ODOO_ADDONS}" --config "${ODOO_CONFIG}" --backup community
--addons "${ODOO_ADDONS}" --config "${ODOO_CONFIG}" --backup "${VERSION}"
Show 0 " Generate Config Complete"
}