From c4c74cda65626f53d0f5e9922f40a80a12864070 Mon Sep 17 00:00:00 2001 From: han0 Date: Mon, 13 Oct 2025 15:21:26 +0800 Subject: [PATCH] fix: ci --- .gitea/workflows/ci.yaml | 48 ++++++++++++++++++++++++++++++++ web/api/components/data.py | 2 +- web/commons/models/mixin/base.py | 6 ++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..ecddbc3 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,48 @@ +name: ci + +on: + push: + branches: + - test + +env: + DEPLOY_PATH: /home/opt/app/material-api + DEPLOY_TEST_HOST_IP: 172.17.0.1 + +jobs: + build: + runs-on: ubuntu-latests + container: + image: python:3.7.16 + + steps: + - name: Checkout + run: | + git clone --depth 1 "http://test:89085111dd6939710a992d6404bd61a50e420685@8.138.239.222:20300/${GITHUB_REPOSITORY}.git" . + git checkout "${GITHUB_SHA}" + + - name: Build + run: | + mkdir dist + PYTHONUSERBASE=$CI_PROJECT_DIR/home pip install --upgrade pip -i https://mirror.aliyun.com/pypi/simple --user + PYTHONUSERBASE=$CI_PROJECT_DIR/home pip install -r ./requirements.txt -i https://mirror.aliyun.com/pypi/simple --user + rsync -ha ./ ./dist --exclude=dist --exclude=.git --delete + + - name: Deploy + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config + echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh -o StrictHostKeyChecking=no root@$DEPLOY_TEST_HOST_IP "mkdir -p $DEPLOY_PATH" + + rsync -r ./dist/ ${DEPLOY_DEV_HOST_IP}:${DEPLOY_PATH} --delete + ssh ${SSH_OPTS} ${DEPLOY_DEV_HOST_IP} "cd ${DEPLOY_PATH} && source /etc/profile && docker-compose up -d --force-recreate" + + ssh root@$DEPLOY_TEST_HOST_IP "rm -f $DEPLOY_PATH/*.jar" + scp ruoyi-admin/target/ruoyi-admin.jar root@$DEPLOY_TEST_HOST_IP:$DEPLOY_PATH/ + ssh root@$DEPLOY_TEST_HOST_IP "mv $DEPLOY_PATH/ruoyi-admin.jar $DEPLOY_PATH/app.jar" + scp docker-compose.test.yml root@$DEPLOY_TEST_HOST_IP:$DEPLOY_PATH/ + ssh root@$DEPLOY_TEST_HOST_IP "mv $DEPLOY_PATH/docker-compose.test.yml $DEPLOY_PATH/docker-compose.yml" + ssh root@$DEPLOY_TEST_HOST_IP "cd $DEPLOY_PATH && docker compose up -d --force-recreate" diff --git a/web/api/components/data.py b/web/api/components/data.py index ecf9cde..c6c626f 100644 --- a/web/api/components/data.py +++ b/web/api/components/data.py @@ -38,7 +38,7 @@ def refresh_task(task_id): class CalculateQuery(BaseModel): year: int = Field(title='年份') month: int = Field(title='月份') - only_avg: int = Field(title='是否只计算均值') + only_avg: int = Field(title='是否只计算均值', default=0) @data.route('/calculate', methods=['GET']) diff --git a/web/commons/models/mixin/base.py b/web/commons/models/mixin/base.py index f29e554..001d3c5 100644 --- a/web/commons/models/mixin/base.py +++ b/web/commons/models/mixin/base.py @@ -6,6 +6,12 @@ class BaseModelMixin: def upsert(self): result = self.find_by_key() session = self._db.session + # # 住建厅数据初始化 + # if result: + # result.price_fujian = self.price_fujian + # result.fluctuating_fujian = self.fluctuating_fujian + # session.add(result) + # session.commit() if result: session.delete(result) session.flush()