From 680a2c89aae345b602de932b5c2b65586e8aa2ee Mon Sep 17 00:00:00 2001 From: engigu Date: Wed, 3 Jan 2024 11:20:20 +0800 Subject: [PATCH] add custom depoly action --- .github/workflows/custom_deploy.yml | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/custom_deploy.yml diff --git a/.github/workflows/custom_deploy.yml b/.github/workflows/custom_deploy.yml new file mode 100644 index 0000000..35c87d9 --- /dev/null +++ b/.github/workflows/custom_deploy.yml @@ -0,0 +1,56 @@ +name: custom-deploy-your-server + + +on: + workflow_dispatch: + push: + branches: [ "dev" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "20.x" + go-version: '>=1.20.2' + cache: true + + - name: Install npm dependencies + run: npm i + working-directory: web/ + + - name: Run npm build + run: export NODE_ENV=prod && npm run build + working-directory: web/ + + - name: Check build static + run: ls dist/ -la + working-directory: web/ + + - name: Install GO modules + run: go mod tidy + + - name: Build Go + run: go build -o Message-Nest + + - name: Copy files to server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWD }} + source: "Message-Nest" + target: ${{ secrets.REMOTE_TARGER }} + + - name: SSH into server and restart service + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWD }} + script: | + ${{ secrets.REMOTE_SCRIPT }}