Skip to content

Commit

Permalink
feat: Re-enable health check endpoint and add Render CLI installation…
Browse files Browse the repository at this point in the history
… steps in GitHub Actions workflow
  • Loading branch information
AhmedNassar7 committed Dec 18, 2024
1 parent 0380d96 commit 0366011
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ jobs:
run: |
poetry export --without-hashes -o requirements.txt
# - name: Install Render CLI
# run: |
# npm install -g render-cli
# echo 'export PATH="$PATH:$(npm bin -g)"' >> $GITHUB_ENV
# echo "Render CLI installation complete."

# - name: Verify Render CLI Installation
# run: |
# echo "Verifying Render CLI"
# render --version # Check if render command works

# - name: Deploy to Render
# env:
# SECRET_KEY: ${{ secrets.SECRET_KEY }}
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# run: |
# echo "Starting deployment to Render..."
# render deploy --config render.yaml --service-name egypt-metro
# echo "Deployment complete!"
- name: Install Render CLI
run: |
npm install -g render-cli
echo 'export PATH="$PATH:$(npm bin -g)"' >> $GITHUB_ENV
echo "Render CLI installation complete."
- name: Verify Render CLI Installation
run: |
echo "Verifying Render CLI"
render --version # Check if render command works
- name: Deploy to Render
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
echo "Starting deployment to Render..."
render deploy --config render.yaml --service-name egypt-metro
echo "Deployment complete!"
4 changes: 2 additions & 2 deletions egypt_metro/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""
from django.contrib import admin
from django.urls import path, include
# from .views import health_check
from .views import health_check
# from django.conf import settings
# from django.conf.urls.static import static
from drf_yasg.views import get_schema_view
Expand Down Expand Up @@ -47,7 +47,7 @@
path("api/stations/", include("apps.stations.urls")), # Stations and trips

# Miscellaneous
# path("health/", health_check, name="health_check"), # Health check
path("health/", health_check, name="health_check"), # Health check

# Documentation
# path(
Expand Down
32 changes: 16 additions & 16 deletions egypt_metro/views.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# import logging
import logging
from django.http import JsonResponse
# from django.db import connection
from django.db import connection

# logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)


# def health_check(request):
# """
# Health check view to verify the application is running properly.
# """
# try:
# # Check database connection
# with connection.cursor() as cursor:
# cursor.execute("SELECT 1;")
def health_check(request):
"""
Health check view to verify the application is running properly.
"""
try:
# Check database connection
with connection.cursor() as cursor:
cursor.execute("SELECT 1;")

# # Return a success response
# return JsonResponse({"status": "ok"}, status=200)
# Return a success response
return JsonResponse({"status": "ok"}, status=200)

# except Exception as e:
# logger.error("Health check failed", exc_info=e)
# return JsonResponse({"status": "error", "message": str(e)}, status=500)
except Exception as e:
logger.error("Health check failed", exc_info=e)
return JsonResponse({"status": "error", "message": str(e)}, status=500)


def custom_404(request, exception=None):
Expand Down

0 comments on commit 0366011

Please sign in to comment.