Skip to content

CD Pipeline

CD Pipeline #23

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: Fix Permissions
run: |
sudo chmod -R 775 vendor
sudo chown -R $USER:$USER vendor
- name: Clean Vendor Directory
run: |
if [ -d "vendor" ]; then
chmod -R 775 vendor
rm -rf vendor
fi
- name: Stop and remove existing containers
run: |
docker-compose down || true
- name: Deploy with Docker Compose
run: |
docker-compose up -d
- name: Clean up old images
run: |
docker image prune -f