This repository has been archived on 2024-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
Auto-Homelab/.forgejo/workflows/CD.yml
mafyuh 630cbee68f
Some checks failed
Continuous Deployment / deploy (push) Failing after 3s
Update .forgejo/workflows/CD.yml
2024-06-09 04:37:15 +00:00

41 lines
1.1 KiB
YAML

name: Continuous Deployment
on:
push:
branches:
- main
jobs:
deploy:
runs-on: docker
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