name: Continuous Deployment on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Configure SSH Key run: echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa - name: Deploy to Hosts run: | for folder in $(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | cut -d/ -f1 | sort | uniq) do case $folder in arrs) host="${{ secrets.ARRS_IP }}" ;; ag_main) host="${{ secrets.AGMAIN_IP }}" ;; downloaders) host="${{ secrets.DOWNLOADERS_IP }}" ;; # Add cases for other folders/hosts *) echo "Unknown folder: $folder" continue ;; esac echo "Deploying to $host for folder $folder" ssh -o StrictHostKeyChecking=no mafyuh@$host "cd /Auto-Homelab/$folder && git pull && docker-compose up -d" done