52 lines
1.9 KiB
YAML
52 lines
1.9 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- test
|
|
|
|
env:
|
|
MAVEN_OPTS: >-
|
|
-Dhttps.protocols=TLSv1.2
|
|
-Dmaven.repo.local=${{ github.workspace }}/.m2/repository
|
|
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
|
|
-Dorg.slf4j.simpleLogger.showDateTime=true
|
|
-Djava.awt.headless=true
|
|
MAVEN_CLI_OPTS: >-
|
|
--batch-mode --errors --fail-at-end --show-version
|
|
--settings ${{ github.workspace }}/.gitea/.m2/settings.xml
|
|
-DinstallAtEnd=true -DdeployAtEnd=true
|
|
DEPLOY_PATH: /home/opt/app/material-manage-service
|
|
DEPLOY_TEST_HOST_IP: 172.17.0.1
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
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: |
|
|
mvn $MAVEN_CLI_OPTS clean compile package -Dmaven.test.skip=true $MAVEN_OPTS
|
|
|
|
- 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"
|
|
ssh root@$DEPLOY_TEST_HOST_IP "rm -f $DEPLOY_PATH/*.jar"
|
|
scp target/material-manage-service-*-SNAPSHOT.jar root@$DEPLOY_TEST_HOST_IP:$DEPLOY_PATH/
|
|
ssh root@$DEPLOY_TEST_HOST_IP "mv $DEPLOY_PATH/material-manage-service-*-SNAPSHOT.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"
|