[build] build inside alma #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy Go Project | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: almalinux:8.10 # Build inside AlmaLinux 8.10 container | |
| steps: | |
| # Install required system tools | |
| - name: Install system dependencies | |
| run: | | |
| dnf -y install wget tar make git | |
| # Install Go 1.24.3 manually | |
| - name: Install Go 1.24.3 | |
| run: | | |
| wget https://go.dev/dl/go1.24.3.linux-amd64.tar.gz | |
| tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz | |
| echo "export PATH=/usr/local/go/bin:$PATH" >> ~/.bashrc | |
| echo "/usr/local/go/bin" >> $GITHUB_PATH | |
| go version | |
| # Checkout repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Install project dependencies | |
| - name: Install project deps | |
| run: make install | |
| # Build project | |
| - name: Build project | |
| run: make build | |
| # Verify output exists | |
| - name: Verify build output | |
| run: ls -lh ./bin/main | |
| # Setup SSH key for deploy | |
| - 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 -f /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 start /home/tulucentre/main --name file-server || pm2 restart file-server' |