Files
material-api/.gitea/workflows/ci.yaml
han0 28b1e67f48
Some checks failed
ci / build (push) Failing after 1m54s
fix: ci
2025-10-13 16:04:53 +08:00

49 lines
1.8 KiB
YAML

name: ci
on:
push:
branches:
- test
env:
DEPLOY_PATH: /home/opt/app/material-api
DEPLOY_TEST_HOST_IP: 172.17.0.1
jobs:
build:
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://mirrors.aliyun.com/pypi/simple --user
PYTHONUSERBASE=$CI_PROJECT_DIR/home pip install -r ./requirements.txt -i https://mirrors.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"