From 6c5c810e08e22194f74cfb30a3be03a9e1bbe3fa Mon Sep 17 00:00:00 2001 From: zchengo <1933757688@qq.com> Date: Tue, 6 Dec 2022 12:37:10 +0800 Subject: [PATCH] initial workflows --- .github/workflows/deploy.yaml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..81cc3f4 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,39 @@ +name: CRM CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.12.0' + + - name: Build Web + run: cd web && npm install && npm run build + + - name: Use Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Build Server + run: cd server && go mod tidy && go build -o crmserver main.go + + - name: Deploy CRM + env: + KEY: ${{ secrets.SSH_PRIVATE_KEY }} + HOST: ${{ secrets.REMOTE_HOST }} + run: | + mkdir -p ~/.ssh/ && echo "$KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + scp -o StrictHostKeyChecking=no -r web/dist ubuntu@${HOST}:/usr/local/nginx/html/ + ssh -o StrictHostKeyChecking=no ubuntu@${HOST} "sudo /usr/local/nginx/sbin/nginx -s reload" + scp -o StrictHostKeyChecking=no -r server/crmserver ubuntu@${HOST}:/home/ubuntu/ + ssh -o StrictHostKeyChecking=no ubuntu@${HOST} "sudo /home/ubuntu/crmapi/restart.sh > /dev/null 2>&1 &" \ No newline at end of file