NEWAuto-scale sesuai traffic
Bonus 25%!0h
Detail
cicdgitlabpipelinedeploymenthelipodtutorial

CI/CD dengan GitLab: Auto Deploy Setiap Push ke Repository

Tim Helipod

5 menit baca

Automate deployment dari GitLab ke Helipod. Setiap push ke branch tertentu bisa otomatis trigger build dan deploy — tidak perlu deploy manual dari dashboard.

Deploy manual dari dashboard itu oke untuk sekali-sekali. Tapi untuk workflow harian, kamu butuh CI/CD pipeline yang otomatis: push kode, pipeline jalan, aplikasi ter-deploy.

Helipod mendukung integrasi langsung dengan GitLab. Setiap push ke branch tertentu bisa otomatis trigger build dan deploy. Tidak perlu script tambahan atau server CI sendiri.

Kenapa CI/CD?

Tanpa CI/CD Dengan CI/CD
Deploy manual dari dashboard Auto deploy setiap push
Mudah lupa step Pipeline terstandarisasi
Sulit track perubahan Setiap deploy tercatat
Human error Konsisten dan reliable

Cara Setup GitLab CI/CD

Langkah 1: Hubungkan Repository

  1. Buka halaman project di Helipod
  2. Tab SettingsGit
  3. Pilih GitLab sebagai provider
  4. Login dengan akun GitLab kamu
  5. Pilih repository yang ingin dihubungkan

Langkah 2: Konfigurasi Pipeline

Helipod akan otomatis detect .gitlab-ci.yml di repository kamu. Kalau belum ada, buat file tersebut di root project:

stages:
  - build
  - deploy

build:
  stage: build
  image: node:20-alpine
  script:
    - yarn install --frozen-lockfile
    - yarn build
  artifacts:
    paths:
      - dist/
      - node_modules/
    expire_in: 1 hour

deploy:
  stage: deploy
  image: alpine:latest
  script:
    - echo "Deploying to Helipod..."
  only:
    - main

Langkah 3: Set Environment Variables di GitLab

Agar pipeline bisa berinteraksi dengan Helipod, set environment variables di GitLab:

  1. Buka project di GitLab
  2. SettingsCI/CDVariables
  3. Tambahkan:
Variable Deskripsi
HELIPOD_API_KEY API key dari Helipod
HELIPOD_PROJECT_ID ID project Helipod

Langkah 4: Push dan Deploy

Setelah konfigurasi selesai:

git add .
git commit -m "feat: add new feature"
git push origin main

Pipeline akan otomatis jalan dan deploy ke Helipod.

Workflow yang Direkomendasikan

Branch Strategy

main       → Production (auto deploy)
staging    → Staging (auto deploy)
feature/*  → Preview environment (on demand)

Merge Request Flow

  1. Buat branch dari main
  2. Push kode ke branch
  3. Buat Merge Request
  4. Pipeline jalan (build + test)
  5. Review dan merge
  6. Auto deploy ke production

Environment Per Branch

Helipod bisa membuat environment terpisah untuk setiap branch:

deploy_staging:
  stage: deploy
  script:
    - deploy to staging environment
  only:
    - staging

deploy_production:
  stage: deploy
  script:
    - deploy to production environment
  only:
    - main

Untuk penjelasan environment, baca: Environment Variables di Helipod

Auto Deploy dari Helipod

Selain GitLab CI, Helipod juga punya auto-deploy built-in:

  1. Hubungkan repository GitLab
  2. Pilih branch untuk production (biasanya main)
  3. Aktifkan Auto Deploy
  4. Setiap push ke branch tersebut akan otomatis deploy

Konfigurasi Auto Deploy

  • Build command — perintah build (misal: yarn build)
  • Start command — perintah start (misal: yarn start)
  • Dockerfile — kalau pakai Dockerfile custom
  • Environment variables — konfigurasi yang dibutuhkan

Untuk panduan Dockerfile, baca: Cara Membuat Dockerfile untuk Deploy

Monitoring Pipeline

Dari Dashboard Helipod

  1. Tab Deployments
  2. Lihat status setiap deployment
  3. Klik untuk lihat build logs

Dari GitLab

  1. Buka project di GitLab
  2. Tab CI/CDPipelines
  3. Lihat status dan logs

Dari Heli Crew

Kamu → "cek deployment terakhir service api-backend"
Heli Crew → [memanggil get_deployments]
           → "Deployment terakhir:
              - Commit: feat: add payment integration
              - Status: Success
              - Duration: 2m 34s
              - Deployed: 5 menit yang lalu"

Untuk penjelasan lengkap monitoring, baca: Monitoring dan Logs Real-time

Tips CI/CD

1. Gunakan Cache

Cache dependencies di pipeline untuk build yang lebih cepat:

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - .next/cache/

2. Parallel Jobs

Jalankan test dan build secara parallel untuk menghemat waktu:

test:
  stage: build
  script: yarn test

lint:
  stage: build
  script: yarn lint

build:
  stage: build
  script: yarn build
  needs: [test, lint]

3. Environment Variables di Pipeline

Akses environment variables dari pipeline:

deploy:
  script:
    - echo "Deploying to $ENVIRONMENT"
    - curl -X POST $HELIPOD_API/deploy
  variables:
    ENVIRONMENT: production

4. Rollback Otomatis

Konfigurasi rollback otomatis jika deploy gagal:

deploy:
  script:
    - deploy_to_helipod
    - verify_health
  after_script:
    - if: $CI_JOB_STATUS == "failed"
      script: rollback_deployment

Troubleshooting

Pipeline Gagal di Build Stage

  • Cek build logs untuk error message
  • Pastikan dependency terinstall dengan benar
  • Cek apakah ada script yang error di package.json

Deploy Gagal

  • Pastikan environment variables sudah benar
  • Cek apakah service di Helipod sudah running
  • Verifikasi koneksi ke database

Auto Deploy Tidak Jalan

  • Pastikan branch yang dipilih benar
  • Cek apakah repository sudah terhubung
  • Verifikasi webhook di GitLab

Untuk troubleshooting lebih lanjut, baca: Cara Membuat Dockerfile untuk Deploy — bagian debugging

Mulai Sekarang

Daftar gratis di helipod.io. Hubungkan repository GitLab dan setup auto deploy dalam hitungan menit.

Butuh bantuan? Hubungi support@helipod.id atau bergabung di komunitas hangar.helipod.io.

Baca juga:

Fitur Terkait

CI/CD Pipeline

Siap coba Helipod?

Deploy aplikasi kamu sekarang. Gratis, tanpa kartu kredit.

Mulai Gratis →