Merge pull request #3 from cyber-evangelists/dev-branch #31
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: Vulnerability | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deployment: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Install sshpass | |
| run: sudo apt-get install -y sshpass | |
| - name: Add VM to known_hosts | |
| run: | | |
| mkdir -p ~/.ssh | |
| ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts | |
| - name: Verify known_hosts Entry | |
| run: | | |
| cat ~/.ssh/known_hosts # Optional step to confirm the host is added | |
| - name: Synchronize Code with VM Using rsync and sshpass | |
| env: | |
| PASSWORD: ${{ secrets.PASSWORD }} | |
| run: | | |
| sshpass -p "$PASSWORD" rsync -avz --exclude='.git' --exclude='.env' \ | |
| --no-perms --omit-dir-times --no-group \ | |
| -e "ssh -o StrictHostKeyChecking=no" ./ ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/home/dev/CAPEC-Rag/ | |
| - name: Restart Docker Compose Services | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.VM_HOST }} | |
| username: ${{ secrets.VM_USER }} | |
| password: ${{ secrets.PASSWORD }} | |
| script: | | |
| echo "Stopping existing Docker Compose services..." | |
| cd /home/dev/CAPEC-Rag/ | |
| docker-compose down | |
| echo "Starting Docker Compose services..." | |
| docker-compose build --no-cache | |
| docker-compose up -d | |
| echo "Successfully deployed the application!" |