Skip to content

Commit 422166d

Browse files
committed
Enhance AWS App Runner deployment workflow: update environment input options for consistency, improve deployment status checks, and ensure accurate error handling during service updates.
1 parent fbca642 commit 422166d

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/deploy-apprunner.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ on:
66
environment:
77
description: 'Deployment environment'
88
required: true
9-
# PERBAIKAN: Mengubah default agar cocok dengan nama environment Anda
109
default: 'Production'
1110
type: choice
1211
options:
13-
# PERBAIKAN: Mengubah opsi agar cocok
1412
- Production
1513
- staging
1614
push:
@@ -30,7 +28,6 @@ jobs:
3028
deploy:
3129
name: Build and Deploy to App Runner
3230
runs-on: ubuntu-latest
33-
# PERBAIKAN: Mengubah default menjadi 'Production' (P besar) agar cocok dengan environment Anda
3431
environment: ${{ github.event.inputs.environment || 'Production' }}
3532

3633
steps:
@@ -74,12 +71,24 @@ jobs:
7471
echo "Updating existing App Runner service: $SERVICE_ARN"
7572
aws apprunner start-deployment --service-arn $SERVICE_ARN
7673
77-
# Menambahkan loop untuk menunggu deployment selesai
78-
echo "Waiting for deployment to complete..."
79-
timeout 10m aws apprunner wait service-stable --service-arn $SERVICE_ARN
80-
echo "Deployment finished successfully!"
74+
# PERBAIKAN: Menggunakan perintah 'wait' yang benar dan menambahkan pengecekan status akhir
75+
echo "Waiting for service to become stable..."
76+
# Menunggu hingga layanan kembali ke status RUNNING, dengan timeout 10 menit
77+
aws apprunner wait service-status-running --service-arn $SERVICE_ARN
78+
79+
echo "Deployment finished. Checking final operation status..."
80+
# Mengambil status operasi deployment terakhir
81+
LATEST_OP_STATUS=$(aws apprunner list-operations --service-arn $SERVICE_ARN --max-results 1 --query "OperationSummaryList[0].Status" --output text)
82+
83+
if [ "$LATEST_OP_STATUS" == "SUCCEEDED" ]; then
84+
echo "✅ Deployment Succeeded!"
85+
else
86+
echo "❌ Deployment resulted in status: $LATEST_OP_STATUS"
87+
# Membuat job gagal jika deployment tidak berhasil
88+
exit 1
89+
fi
8190
else
8291
echo "Service '${{ env.APP_RUNNER_SERVICE_NAME }}' not found. Please create it manually."
8392
echo "Use Image URI: ${{ steps.build-image.outputs.image_uri }}"
84-
# exit 1 # Opsional: buat job gagal jika service tidak ditemukan
93+
exit 1 # Membuat job gagal jika service tidak ditemukan
8594
fi

0 commit comments

Comments
 (0)