Skip to content

Commit 5f81157

Browse files
ci: update .env echo
1 parent 3f5c2bb commit 5f81157

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

.github/workflows/deploy-backend.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths:
77
- "backend/**"
88
- ".github/workflows/deploy-backend.yml"
9-
- '!**/**/*.md'
9+
- "!**/**/*.md"
1010
workflow_dispatch:
1111

1212
# ✅ 1. WAJIB DEFINISIKAN ENV DI ROOT AGAR TIDAK NYASAR KE DOCKER HUB!
@@ -49,11 +49,11 @@ jobs:
4949
# ==========================================================
5050
build-and-push-ghcr:
5151
name: 2. Build & Push Docker Image to GHCR
52-
needs: build-and-test # ✅ KUNCI: Harus nunggu Job 1 sukses!
52+
needs: build-and-test # ✅ KUNCI: Harus nunggu Job 1 sukses!
5353
runs-on: ubuntu-latest
5454
permissions:
5555
contents: read
56-
packages: write # ✅ KUNCI: Izin push ke GHCR
56+
packages: write # ✅ KUNCI: Izin push ke GHCR
5757

5858
steps:
5959
- name: Checkout repository
@@ -96,7 +96,7 @@ jobs:
9696
# ==========================================================
9797
deploy-to-production:
9898
name: 3. Deploy to Server & Run Migrations
99-
needs: build-and-push-ghcr # ✅ KUNCI: Harus nunggu Job 2 sukses!
99+
needs: build-and-push-ghcr # ✅ KUNCI: Harus nunggu Job 2 sukses!
100100
runs-on: ubuntu-latest
101101
environment: staging
102102

@@ -113,7 +113,7 @@ jobs:
113113
key: ${{ secrets.SSH_PRIVATE_KEY }}
114114
source: "backend/docker-compose.yml"
115115
target: "${{ secrets.DEPLOY_PATH_BACKEND }}"
116-
strip_components: 1 # ✅ KUNCI: Letakkan langsung docker-compose.yml di target!
116+
strip_components: 1 # ✅ KUNCI: Letakkan langsung docker-compose.yml di target!
117117

118118
- name: Deploy & Execute DB Migrations via SSH
119119
uses: appleboy/ssh-action@v1.0.3
@@ -123,7 +123,7 @@ jobs:
123123
port: ${{ secrets.SERVER_PORT || '22' }}
124124
key: ${{ secrets.SSH_PRIVATE_KEY }}
125125
command_timeout: 30m
126-
script_stop: true # ✅ KUNCI: Hentikan langsung jika ada error 1 pun!
126+
script_stop: true # ✅ KUNCI: Hentikan langsung jika ada error 1 pun!
127127
script: |
128128
echo "=========================================================="
129129
echo " [1/5] Masuk ke direktori aplikasi"
@@ -137,9 +137,7 @@ jobs:
137137
echo " [2/5] Menulis file .env production"
138138
echo "=========================================================="
139139
# Menulis file .env di level direktori yang sama dengan docker-compose.yml
140-
cat <<'EOF_ENV' > .env
141-
${{ secrets.ENV_PROD_BACKEND }}
142-
EOF_ENV
140+
echo "${{ secrets.ENV_PROD_BACKEND }}" | base64 -d > .env
143141
chmod 600 .env
144142
145143
echo "=========================================================="
@@ -166,4 +164,4 @@ jobs:
166164
echo "=========================================================="
167165
docker compose up -d --force-recreate --remove-orphans
168166
docker image prune -f
169-
echo "✅ Deployment dan Migrasi Database selesai!"
167+
echo "✅ Deployment dan Migrasi Database selesai!"

0 commit comments

Comments
 (0)