diff --git a/.github/workflows/devops-test.yaml b/.github/workflows/devops-test.yaml new file mode 100644 index 00000000..bbdf270d --- /dev/null +++ b/.github/workflows/devops-test.yaml @@ -0,0 +1,55 @@ +name: devops-test +on: + push: + branches: [test] + workflow_dispatch: +jobs: + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['16.x'] + go-version: ['1.16'] + steps: + - name: Check out branch + uses: actions/checkout@v2 + - name: Sed Config + env: + PROD: ${{ secrets.PROD }} + TESTING: ${{ secrets.TESTING }} + shell: bash + run: | + git branch + ls -l + sed -i "s/${PROD}/${TESTING}/g" web/.env.production + sed -i 's/${basePath}:${basePort}/${basePath}/g' web/src/view/systemTools/formCreate/index.vue + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.1.2 + with: + node-version: ${{ matrix.node-version }} + - name: Build-Node + run: | + cd web/ && yarn install && yarn run build + - name: Use Go ${{ matrix.go-version }} + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Build-go + run: | + cd server/ && go mod tidy && go build && mkdir ../web/ser && mv server ../web/ser/ && cd ../web/ser/ && ls -s + - name: restart + env: + KEY: ${{ secrets.KEY }} + HOST: ${{ secrets.HOST }} + USER: ${{ secrets.USER }} + PROT: ${{ secrets.PROT }} + MKDIRTEST: ${{ secrets.MKDIRTEST }} + run: | + mkdir -p ~/.ssh/ && echo "$KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + scp -P ${PROT} -o StrictHostKeyChecking=no -r web/dist/* ${USER}@${HOST}:${MKDIRTEST}dist/ + scp -P ${PROT} -o StrictHostKeyChecking=no -r web/ser/* ${USER}@${HOST}:${MKDIRTEST} + ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST}resource/ && rm -rf ${MKDIRTEST}resource/*" + scp -P ${PROT} -o StrictHostKeyChecking=no -r server/resource/* ${USER}@${HOST}:${MKDIRTEST}resource/ + ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST} && bash restart.sh > /dev/null 2>&1 &" diff --git a/web/.env.production b/web/.env.production index 79ba49a3..2e3d72d8 100644 --- a/web/.env.production +++ b/web/.env.production @@ -4,4 +4,4 @@ VITE_CLI_PORT = 8080 VITE_SERVER_PORT = 8888 VITE_BASE_API = /api #下方修改为你的线上ip -VITE_BASE_PATH = http://8.141.61.63 \ No newline at end of file +VITE_BASE_PATH = https://demo.gin-vue-admin.com