# Step 7 - Implementasi GitHub, Staging, Production

Step 7 menambahkan lapisan operasional agar project siap dipakai dengan alur:

```text
Local source
GitHub private repository
develop -> staging Rumahweb
main -> production Rumahweb
```

## File baru

```text
scripts/create_env.php
scripts/deploy_ready.php
scripts/init_git_branches.sh
scripts/step7_smoke_test.php
deploy/checklists/github-cpanel-step7.md
deploy/checklists/production-cutover-step7.md
README_DEPLOY_RUMAHWEB_STEP7.md
```

## Setup GitHub pertama kali

Jalankan dari root project:

```bash
bash scripts/init_git_branches.sh git@github.com:OWNER/REPO.git
git push -u origin main
git push -u origin develop
```

Ganti `OWNER/REPO` dengan repository private milik rumah sakit atau akun Bapak.

## Setup staging

Di server staging:

```bash
php scripts/create_env.php staging
nano .env
php scripts/post_deploy.php
php scripts/preflight.php
php scripts/deploy_ready.php staging
php scripts/migrate.php status
php scripts/step7_smoke_test.php
```

Jika database staging masih kosong:

```bash
php scripts/migrate.php up
```

## Setup production

Di server production:

```bash
php scripts/create_env.php production
nano .env
php scripts/post_deploy.php
php scripts/preflight.php
php scripts/deploy_ready.php production
php scripts/backup_files.php
php scripts/backup_database.php
php scripts/migrate.php status
```

Jika ada migration baru yang memang perlu diterapkan:

```bash
php scripts/migrate.php up
```

## Catatan penting

Jangan commit file `.env`. File ini harus dibuat langsung di staging dan production.

Folder berikut juga tidak boleh ditimpa deploy:

```text
uploads/
exports/
storage/logs/
storage/cache/
storage/exports/
storage/backups/
```
