Deploy GAX
How to deploy GAX - Go Static Site Generator to GitHub Pages, Vercel, Netlify, VPS and cPanel
GAX generates static files into dist/ folder. Deploy that folder anywhere.
Build
go mod tidy
go build -o gax ./cmd/gax
./gax build
# output: ./dist
1. GitHub Pages
Create .github/workflows/deploy.yml:
name: Deploy GAX to GitHub Pages
on:
push:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: |
go build -o gax ./cmd/gax
./gax build
- uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
Go to Settings -> Pages -> Source: GitHub Actions
2. Vercel
Create vercel.json:
{
"buildCommand": "go build -o gax ./cmd/gax && ./gax build",
"outputDirectory": "dist",
"framework": null
}
Deploy via CLI:
npm i -g vercel
vercel --prod
3. Netlify
Create netlify.toml:
[build]
command = "go build -o gax ./cmd/gax && ./gax build"
publish = "dist"
[build.environment]
GO_VERSION = "1.22"
Deploy via CLI:
npm i -g netlify-cli
netlify deploy --prod --dir=dist
4. VPS (Ubuntu + Nginx)
Create .github/workflows/deploy-vps.yml:
name: Deploy to VPS
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: |
go build -o gax ./cmd/gax
./gax build
- uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_KEY }}
REMOTE_HOST: ${{ secrets.VPS_HOST }}
REMOTE_USER: ${{ secrets.VPS_USER }}
SOURCE: "dist/"
TARGET: "/var/www/gax"
Nginx config /etc/nginx/sites-available/gax:
server {
listen 80;
server_name yourdomain.com;
root /var/www/gax;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
Manual deploy:
rsync -avz --delete dist/ user@your-vps-ip:/var/www/gax/
5. cPanel / Shared Hosting via FTP
Create .github/workflows/deploy-cpanel.yml:
name: Deploy to cPanel
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: |
go build -o gax ./cmd/gax
./gax build
- uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/
server-dir: ./public_html/
Manual deploy:
lftp -u USER,PASS HOST -e "mirror -R dist/ public_html/; quit"
GitHub Secrets
Add these in Settings -> Secrets and variables -> Actions:
VPS_SSH_KEY- private SSH keyVPS_HOST- your VPS IPVPS_USER- ssh user (root / ubuntu)FTP_SERVER- ftp.yourdomain.comFTP_USERNAME- cPanel FTP userFTP_PASSWORD- cPanel FTP password
GAX is static, no Node.js, no database. Just upload dist/ anywhere.