feat: Update development workflow to meet Task 2 requirements #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Development | |
| # Test workflow with ACTIONS token | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| COMPOSE_FILE: docker-compose.dev.yml | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.ACTIONS }} | |
| - name: Setup Environment | |
| run: | | |
| echo "Setting up environment..." | |
| if [ ! -f .env ]; then | |
| echo "Creating .env file..." | |
| cp .env.example .env || echo "No .env.example found, skipping..." | |
| fi | |
| # Set development port prefix for the containers | |
| echo "DEV_PORT_PREFIX=30" >> .env | |
| - name: Load Environment Variables | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Setup Docker | |
| run: | | |
| echo "Current user and groups:" | |
| id | |
| echo "Docker info:" | |
| docker info || true | |
| echo "Ensuring docker group membership..." | |
| if ! groups | grep -q docker; then | |
| echo "::warning::Current user is not in docker group" | |
| fi | |
| - name: Build and Deploy Services | |
| run: | | |
| echo "Building and deploying services..." | |
| docker compose -f $COMPOSE_FILE down --remove-orphans | |
| docker compose -f $COMPOSE_FILE build --no-cache | |
| docker compose -f $COMPOSE_FILE up -d | |
| - name: Verify Deployment | |
| run: | | |
| echo "Checking running containers..." | |
| docker compose -f $COMPOSE_FILE ps | |
| echo "Waiting for services to be healthy..." | |
| for i in {1..12}; do | |
| if docker compose -f $COMPOSE_FILE ps | grep -q "unhealthy\|exit"; then | |
| echo "Some containers are unhealthy or have exited" | |
| docker compose -f $COMPOSE_FILE logs | |
| exit 1 | |
| elif docker compose -f $COMPOSE_FILE ps | grep -q "starting"; then | |
| echo "Some containers are still starting... (attempt $i/12)" | |
| sleep 10 | |
| continue | |
| else | |
| echo "All containers appear to be running!" | |
| # Test frontend | |
| curl -f http://localhost:3005 || echo "Frontend not responding on port 3005" | |
| # Test backend | |
| curl -f http://localhost:3004/api/health || echo "Backend not responding on port 3004" | |
| exit 0 | |
| fi | |
| done | |
| echo "Deployment verification timed out" | |
| docker compose -f $COMPOSE_FILE logs | |
| exit 1 |