Skip to content

CD Pipeline

CD Pipeline #28

Workflow file for this run

name: CD Pipeline
on:
workflow_run:
workflows: ["Build and Push Docker Image"]
types:
- completed
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Docker Hub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Pull Docker images
run: |
docker pull muneer1997/demo_php:latest
docker pull muneer1997/demo_nginx:latest
- name: Stop and remove existing containers
run: |
docker-compose down || true
- name: Deploy with Docker Compose
run: |
docker-compose up -d
- name: Run composer install
run: |
docker exec -it demo_php bash -c "cd /var/www/demo && composer install"
- name: Clean up old images
run: |
docker image prune -f