- SSH setup에 id 추가하여 참조 가능하게 설정 - 조건부 SSH agent cleanup 추가로 경고 제거 - README.md 파일 구조 설명 개선 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
47 lines
1.4 KiB
YAML
47 lines
1.4 KiB
YAML
name: Deploy to Ubuntu Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup SSH key
|
|
id: ssh-setup
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.NAS_SSH_KEY_ADMIN }}
|
|
|
|
- name: Deploy files via SCP
|
|
env:
|
|
HOST: ${{ secrets.NAS_HOST }}
|
|
PORT: ${{ secrets.NAS_PORT }}
|
|
USER: ${{ secrets.NAS_USER }}
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "rm -rf ~/robeing-nginx/* || true; mkdir -p ~/robeing-nginx"
|
|
tar --exclude='.git' -czf - . | ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST "cd ~/robeing-nginx && tar -xzf -"
|
|
|
|
- name: Apply nginx config via SSH
|
|
env:
|
|
HOST: ${{ secrets.NAS_HOST }}
|
|
PORT: ${{ secrets.NAS_PORT }}
|
|
USER: ${{ secrets.NAS_USER }}
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no -o RequestTTY=no -p $PORT $USER@$HOST << 'EOF'
|
|
cd ~/robeing-nginx
|
|
sudo -n /usr/bin/cp server-nginx-default /etc/nginx/sites-available/default
|
|
sudo -n /usr/sbin/nginx -t
|
|
sudo -n /bin/systemctl reload nginx
|
|
docker compose down || true
|
|
EOF
|
|
|
|
- name: Cleanup SSH agent
|
|
if: always() && steps.ssh-setup.outcome == 'success'
|
|
run: |
|
|
ssh-agent -k || true |