Skip to content

[fix] change workflow build command #6

[fix] change workflow build command

[fix] change workflow build command #6

Workflow file for this run

name: Build and Deploy Go Project
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout code
uses: actions/checkout@v4
# Set up Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.3
# Install dependencies
- name: Install dependencies
run: make install
# Build project
- name: Build project
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/main ./cmd/main.go
# Verify output exists
- name: Verify build output
run: ls -lh ./bin/main
# Deploy to server
# Setup SSH key
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.TULUCENTRE_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.TULUCENTRE_SERVER_IP }} >> ~/.ssh/known_hosts
# Stop existing pm2 process
- name: Stop existing pm2 process
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.TULUCENTRE_SERVER_USER }}@${{ secrets.TULUCENTRE_SERVER_IP }} \
'pm2 stop file-server || true; [ -f /home/tulucentre/main ] && rm /home/tulucentre/main || true'
# Copy files to server
- name: Copy files to server
run: |
scp -i ~/.ssh/id_rsa ./bin/main ${{ secrets.TULUCENTRE_SERVER_USER }}@${{ secrets.TULUCENTRE_SERVER_IP }}:/home/tulucentre/
# Restart pm2 process
- name: Restart pm2 process
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.TULUCENTRE_SERVER_USER }}@${{ secrets.TULUCENTRE_SERVER_IP }} \
'pm2 restart file-server'