From da922cbcaa021f27119f705694667ec305bb18be Mon Sep 17 00:00:00 2001 From: Ulvi Haciyev Date: Thu, 14 May 2026 15:54:22 +0400 Subject: [PATCH] feat(MED39): CD pipeline added. --- .github/workflows/deploy.yml | 66 +++++++++++++++++++ .../resources/application-prod.properties | 6 ++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 src/main/resources/application-prod.properties diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f2a385a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,66 @@ +name: MediCare CD + +on: + workflow_run: + workflows: ["MediCare CI"] + types: [completed] + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Trigger Render deploy + run: curl -X POST "${{ secrets.RENDER_DEPLOY_HOOK }}" + + - name: Wait for deployment and verify health + env: + APP_URL: ${{ secrets.RENDER_APP_URL }} + run: | + set -u + if [ -z "${APP_URL:-}" ]; then + echo "::error::Set repository secret RENDER_APP_URL to your service URL (e.g. https://your-app.onrender.com)" + exit 1 + fi + + BASE="${APP_URL%/}" + HEALTH_URL="${BASE}/actuator/health" + + echo "Waiting 90s for Render to rebuild and restart..." + sleep 90 + + MAX_ATTEMPTS=24 + SLEEP_SECS=15 + + for i in $(seq 1 "$MAX_ATTEMPTS"); do + echo "Health check attempt ${i}/${MAX_ATTEMPTS} → ${HEALTH_URL}" + + if response=$(curl -fsS --max-time 30 "$HEALTH_URL" 2>/dev/null); then + if echo "$response" | jq -e '.status == "UP"' >/dev/null 2>&1; then + echo "Health check passed: status is UP" + echo "$response" | jq . + exit 0 + fi + echo "Unexpected payload (expected status UP):" + echo "$response" | head -c 500 + echo + else + echo "curl failed (service not ready or HTTP error)" + fi + + if [ "$i" -lt "$MAX_ATTEMPTS" ]; then + sleep "$SLEEP_SECS" + fi + done + + echo "::error::Health check did not return {\"status\":\"UP\"} after ${MAX_ATTEMPTS} attempts" + exit 1 + + - name: Deployment summary + if: success() + run: | + echo "## Deployment verified" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "Render deploy hook ran and **actuator/health** reported **UP**." >> "$GITHUB_STEP_SUMMARY" \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 0000000..18351fc --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1,6 @@ +spring.datasource.url=${SPRING_DATASOURCE_URL} +spring.datasource.username=${SPRING_DATASOURCE_USERNAME} +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} +spring.datasource.driver-class-name=org.postgresql.Driver +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.hibernate.ddl-auto=update