Skip to content

Deployment & CI/CD

Topologi deployment

Deployment berbasis VPS (bukan container), di-orkestrasi GitHub Actions via SSH.

GitHub Actions

WorkflowTriggerTargetPath
production.ymlpush ke master/var/www/transaksional-email-be.github/workflows/production.yml
develop.ymlpush ke develop/var/www/dashboard-relay-be.github/workflows/develop.yml
review.yml(review).github/workflows/review.yml

Langkah deploy (sama untuk prod & staging):

  1. Install SSH key (secret SSH_KEY / DEV_SSH_KEY).
  2. Test koneksi SSH.
  3. git checkout <branch>.
  4. git pull branch terkait.
  5. npm i.
  6. pm2 reload ecosystem.config.js.

Deploy = git pull + reload

Tidak ada build step, test gate, atau migrasi otomatis dalam pipeline. Migrasi database harus dijalankan manual di server. Pastikan urutan: backup DB → npx sequelize-cli db:migratepm2 reload.

PM2

ecosystem.config.js:

PropertiNilai
namebackend-ate
script./server.js
watchfalse
Log/var/log/backend/{error,out,application}.log
PID/var/log/backend/process.pid

PM2 hanya mengawasi server HTTP. Cluster mode (instances/exec_mode) di-comment (mode single).

bash
pm2 start ecosystem.config.js
pm2 reload ecosystem.config.js
pm2 logs backend-ate
pm2 status

Procfile (Heroku-style)

Procfile hanya mendefinisikan web: npm start. Tidak ada worker/scheduler dyno. URL Heroku di app.js (swagger server) hanya default dokumentasi, bukan bukti hosting saat ini.

Cron di production

Penting

Jadwal cron tidak ada di repo. Cron dijalankan oleh crontab/scheduler di VPS yang memanggil npm run cron:*. Saat handover:

  1. Jalankan crontab -l (atau cek scheduler) di server untuk inventaris job aktif & jadwalnya.
  2. Pastikan cron cron:auth-zoho berjalan sesuai TTL token Zoho (~1 jam).
  3. Cron failure tidak masuk log PM2 — arahkan output cron ke file log terpisah.

Lihat Background Jobs & Cron untuk daftar cron.

Checklist deploy production

  1. Pastikan PR sudah di-review & lulus test lokal.
  2. Backup database production.
  3. Merge ke master (memicu production.yml).
  4. Bila ada perubahan skema: SSH ke server, jalankan migrasi manual.
  5. Verifikasi pm2 status & log.
  6. Smoke test endpoint kritikal (login, checkout, callback).
  7. Pantau log delivery & error beberapa saat setelah deploy.