Initial commit - Full stack RabbitMQ Kafka demo #1
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| rabbitmq: | |
| image: rabbitmq:3-management | |
| ports: | |
| - 5672:5672 | |
| - 15672:15672 | |
| env: | |
| RABBITMQ_DEFAULT_USER: guest | |
| RABBITMQ_DEFAULT_PASS: guest | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:7.4.0 | |
| ports: | |
| - 2181:2181 | |
| env: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 | |
| kafka: | |
| image: confluentinc/cp-kafka:7.4.0 | |
| ports: | |
| - 9092:9092 | |
| env: | |
| KAFKA_BROKER_ID: 1 | |
| KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | |
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092 | |
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Wait for services | |
| run: sleep 30 | |
| - name: Run tests | |
| run: npm test | |
| env: | |
| RABBITMQ_URL: amqp://localhost | |
| KAFKA_BROKERS: localhost:9092 | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'release' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Build Docker image | |
| run: docker build -t rabbitmq-kafka-node-demo:${{ github.event.release.tag_name }} . | |
| - name: Test Docker image | |
| run: | | |
| docker-compose up -d | |
| sleep 30 | |
| docker-compose ps | |
| docker-compose down |