Files
touch-programming/.github/workflows/deploy.yaml
T

54 lines
1.4 KiB
YAML

name: Deployment to VPS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup 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: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Deploy to VPS
env:
SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
ssh-keyscan -H hazemkrimi.tech >> ~/.ssh/known_hosts
rsync -avz --delete client/build deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/public
rsync -avz --delete server/executable deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/api
# scp -r client/build deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/public
# scp server/executable deploy@hazemkrimi.tech:/var/www/touch-programming.hazemkrimi.tech/api