Added RabbitMq in docker-compose and aws security group for rabbitmq #12
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"] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. SETUP & BUILD | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and Push | |
| run: | | |
| docker build -t aaren17/devops-demo:latest . | |
| docker push aaren17/devops-demo:latest | |
| # 2. SMART WAIT (Replaces sleep 60) | |
| - name: Wait for SSH Reachability | |
| timeout-minutes: 2 | |
| run: | | |
| while ! nc -z ${{ secrets.EC2_HOST }} 22; do | |
| sleep 5 | |
| done | |
| # 3. DEPLOY FILES | |
| - name: Copy Files | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| source: "docker-compose.yml,prometheus.yml" | |
| target: "/home/ubuntu/" | |
| # 4. START APPLICATION | |
| - name: Deploy App | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| # Ensure Docker installation is actually finished | |
| sudo cloud-init status --wait | |
| # Run the app | |
| cd /home/ubuntu | |
| docker compose pull | |
| docker compose up -d |