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

45 lines
1.2 KiB
YAML
Raw Normal View History

2024-06-09 00:24:27 -04:00
name: Continuous Deployment
on:
push:
branches:
- main
jobs:
deploy:
2024-06-09 00:37:15 -04:00
runs-on: docker
2024-06-09 00:24:27 -04:00
steps:
- name: Checkout repository
uses: actions/checkout@v4
2024-06-09 00:36:54 -04:00
- name: Configure SSH Key
2024-06-09 00:38:22 -04:00
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
2024-06-09 00:24:27 -04:00
- name: Deploy to Hosts
run: |
2024-06-09 00:36:54 -04:00
for folder in $(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | cut -d/ -f1 | sort | uniq)
2024-06-09 00:24:27 -04:00
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"
2024-06-09 00:29:45 -04:00
ssh -o StrictHostKeyChecking=no mafyuh@$host "cd /Auto-Homelab/$folder && git pull && docker-compose up -d"
done