---
title: "CI/CD dengan GitLab: Auto Deploy Setiap Push ke Repository"
url: "https://helipod.io/blog/cicd-gitlab-helipod"
date: "2026-06-10"
updated: "2026-06-10"
author: "Tim Helipod"
tags: ["cicd", "gitlab", "pipeline", "deployment", "helipod", "tutorial"]
excerpt: "CI/CD dengan GitLab ke Helipod: setiap push ke branch tertentu otomatis trigger build dan deploy, tanpa deploy manual dari dashboard."
---

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

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 **Settings** → **Git**
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:

```yaml
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. **Settings** → **CI/CD** → **Variables**
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:

```bash
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:

```yaml
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](/blog/environment-variables-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](/blog/dockerfile-custom-helipod)

## 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/CD** → **Pipelines**
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](/blog/monitoring-logs-helipod)

## Tips CI/CD

### 1. Gunakan Cache

Cache dependencies di pipeline untuk build yang lebih cepat:

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

### 2. Parallel Jobs

Jalankan test dan build secara parallel untuk menghemat waktu:

```yaml
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:

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

### 4. Rollback Otomatis

Konfigurasi rollback otomatis jika deploy gagal:

```yaml
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](/blog/dockerfile-custom-helipod), bagian debugging

## Mulai Sekarang

Daftar gratis di [helipod.io](https://helipod.io). Hubungkan repository GitLab dan setup auto deploy dalam hitungan menit.

Butuh bantuan? Hubungi support@helipod.io atau bergabung di komunitas [hangar.helipod.io](https://hangar.helipod.io).

> **Baca juga:**
> - [Cara Membuat Dockerfile untuk Deploy](/blog/dockerfile-custom-helipod), panduan Dockerfile lengkap
> - [Monitoring dan Logs Real-time](/blog/monitoring-logs-helipod), pantau aplikasi dari dashboard
> - [Multi-Service Project di Helipod](/blog/multi-service-project-helipod), deploy banyak service sekaligus
