From abf625cf99168b9a8137bfee7fe5bb5783e695e0 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 10 Apr 2025 16:29:54 +0100 Subject: [PATCH] Setup auto deploy with GitHub Actions --- .github/workflows/deploy.yaml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 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..46fcc77 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,52 @@ +name: Deployment to VPS + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 18 + + - name: Build client + run: + cd client + npm install + npm run build + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + + - name: Build server + run: + cd server + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o executable + + - name: Prepare to deploy + run: + mkdir touch-programming.hazemkrimi.tech + mkdir touch-programming.hazemkrimi.tech/public + mkdir touch-programming.hazemkrimi.tech/api + cp -r client/build touch-programming.hazemkrimi.tech/public + cp server/executable touch-programming.hazemkrimi.tech/api + + - name: Deploy to VPS + uses: appleboy/scp-action@v0.1.4 + with: + host: hazemkrimi.tech + username: deploy + key: ${{ secrets.DEPLOY_SSH_KEY }} + source: "touch-programming.hazemkrimi.tech" + target: "/var/www"