Skip to content

Commit 42567af

Browse files
committed
Fix deploy script and sync compose file
1 parent d4a0fce commit 42567af

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,22 @@ jobs:
4747
key: ${{ secrets.VPS_KEY }}
4848
port: 22
4949
script: |
50-
# Masuk folder
5150
cd /var/www/pcb-backend/API-PCB
5251
53-
# Login Docker di dalam VPS (Pakai token otomatis)
54-
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
52+
# 1. PAKSA TIMPA perubahan manual di server dengan yang ada di GitHub
53+
git fetch origin main
54+
git reset --hard origin/main
5555
56-
# Tarik kodingan terbaru (untuk update docker-compose.yml)
57-
git pull origin main
56+
# 2. Login GHCR
57+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
5858
59-
# Tarik Image Docker terbaru dari GHCR
60-
docker pull ghcr.io/${{ env.IMAGE_NAME }}:latest
59+
# 3. Tarik Image Terbaru (Explicit Pull)
60+
docker-compose pull
6161
62-
# Restart Container
63-
docker-compose down
64-
docker-compose up -d
62+
# 4. Restart Container dengan Opsi FORCE
63+
# --force-recreate: Paksa bikin ulang container meski config gak berubah
64+
# --remove-orphans: Hapus container hantu
65+
docker-compose up -d --force-recreate --remove-orphans
6566
66-
# Hapus image lama biar hemat disk
67+
# 5. Bersih-bersih
6768
docker image prune -f

0 commit comments

Comments
 (0)