Skip to content
This repository was archived by the owner on Apr 9, 2026. It is now read-only.

error handling for deletion #470

error handling for deletion

error handling for deletion #470

Workflow file for this run

name: CI/CD Pipeline
# Trigger workflow on push to any branch and PRs to main
on:
push:
branches: ['*']
tags: ['v*.*.*']
pull_request:
branches: ['main']
jobs:
# Add a flag parameter to control whether to run tests
check-tests:
runs-on: ubuntu-latest
outputs:
run-tests: 'true' # Set to false to skip tests
steps:
- run: echo "Checking if tests should run"
test:
runs-on: ubuntu-latest
needs: check-tests
if: needs.check-tests.outputs.run-tests == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies using setup script
run: |
cd backend
chmod +x setup-ci.sh
./setup-ci.sh
# same shell/job so tests can use the same venv
- name: Run tests
run: |
cd backend
source .venv/bin/activate
which pytest
python -m pytest --maxfail=2
env:
TEST_EMAIL_ACCOUNT: ${{ secrets.TEST_EMAIL_ACCOUNT }}
TEST_GOOGLE_CLIENT_ID: ${{ secrets.TEST_GOOGLE_CLIENT_ID }}
TEST_GOOGLE_CLIENT_SECRET: ${{ secrets.TEST_GOOGLE_CLIENT_SECRET }}
TEST_MONGO_URI: ${{ secrets.TEST_MONGO_URI }}
TEST_OPENAI_API_KEY: ${{ secrets.TEST_OPENAI_API_KEY }}
TEST_DEEPSEEK_API_KEY: ${{ secrets.TEST_DEEPSEEK_API_KEY }}
TEST_GOOGLE_API_KEY: ${{ secrets.TEST_GEMINI_API_KEY }}
TEST_SUMMARIZER_PROVIDER: ${{ secrets.TEST_SUMMARIZER_PROVIDER || 'openai' }}
# Add a placeholder job that will always run when tests are disabled
test-skipped:
runs-on: ubuntu-latest
needs: check-tests
if: needs.check-tests.outputs.run-tests != 'true'
steps:
- name: Tests skipped
run: echo "Tests are temporarily disabled"
build-docker:
runs-on: ubuntu-latest
# Depend on both jobs, GitHub Actions will automatically skip the disabled one
needs: [test, test-skipped]
# Only run this job for tagged versions or main branch
if: always() && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && (needs.test.result == 'success' || needs.test.result == 'skipped') && (needs.test-skipped.result == 'success' || needs.test-skipped.result == 'skipped')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Check if Docker Hub credentials are available
- name: Check Docker Hub credentials
id: check-docker-credentials
run: |
if [[ -n "${{ secrets.DOCKER_USERNAME }}" && -n "${{ secrets.DOCKER_PASSWORD }}" ]]; then
echo "has_credentials=true" >> $GITHUB_OUTPUT
else
echo "has_credentials=false" >> $GITHUB_OUTPUT
fi
# Only push to Docker Hub if we have the secrets configured
- name: Login to Docker Hub
if: steps.check-docker-credentials.outputs.has_credentials == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build and optionally push backend image
- name: Build and push Backend Docker image
uses: docker/build-push-action@v6
with:
context: .
file: backend/Dockerfile
tags: |
${{ steps.check-docker-credentials.outputs.has_credentials == 'true' && format('{0}/emailessence-backend:{1}', secrets.DOCKER_USERNAME, startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest') || 'emailessence-backend:latest' }}
push: ${{ steps.check-docker-credentials.outputs.has_credentials == 'true' }}
# Build and publish dev Docker image for backend branch
build-docker-dev:
runs-on: ubuntu-latest
# Depend on both jobs, GitHub Actions will automatically skip the disabled one
needs: [test, test-skipped]
# Only run this job for pushes to the backend branch
if: always() && github.ref == 'refs/heads/backend' && (needs.test.result == 'success' || needs.test.result == 'skipped') && (needs.test-skipped.result == 'success' || needs.test-skipped.result == 'skipped')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Check if Docker Hub credentials are available
- name: Check Docker Hub credentials
id: check-docker-credentials
run: |
if [[ -n "${{ secrets.DOCKER_USERNAME }}" && -n "${{ secrets.DOCKER_PASSWORD }}" ]]; then
echo "has_credentials=true" >> $GITHUB_OUTPUT
else
echo "has_credentials=false" >> $GITHUB_OUTPUT
fi
# Only push to Docker Hub if we have the secrets configured
- name: Login to Docker Hub
if: steps.check-docker-credentials.outputs.has_credentials == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build and optionally push backend image with dev tag
- name: Build and push Backend Docker image (dev)
uses: docker/build-push-action@v2
with:
context: .
file: backend/Dockerfile
tags: |
${{ steps.check-docker-credentials.outputs.has_credentials == 'true' && format('{0}/emailessence-backend:dev', secrets.DOCKER_USERNAME) || 'emailessence-backend:dev' }}
push: ${{ steps.check-docker-credentials.outputs.has_credentials == 'true' }}
# This job is informational only - notifying that Render handles deployment
deploy-notification:
runs-on: ubuntu-latest
needs: build-docker
if: success() && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
steps:
- name: Deployment Information
run: |
echo "Docker image build completed successfully."
echo "Deployment to production is handled by Render automatically."
echo "No additional deployment steps needed in GitHub Actions."
- name: Trigger Render Deployment
if: env.RENDER_DEPLOY_HOOK_URL != ''
run: |
curl -X POST ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
env:
RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}