Update deployment to rsync-based NAS deployment
- Replace Docker Hub CI/CD with direct NAS deployment - Use rsync for reliable file synchronization - Add SSH-based remote docker-compose execution - Configure for Synology NAS volume path structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
56eaf8c9b5
commit
7d4d77ce1b
51
.github/workflows/deploy.yml
vendored
51
.github/workflows/deploy.yml
vendored
@ -1,44 +1,31 @@
|
||||
name: Deploy Nginx
|
||||
name: Deploy to NAS (rsync)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Setup SSH key
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.NAS_SSH_KEY_ADMIN }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Rsync to NAS
|
||||
run: |
|
||||
rsync -avz -e "ssh -o StrictHostKeyChecking=no -p ${{ secrets.NAS_PORT }}" ./ \
|
||||
${{ secrets.NAS_USER }}@${{ secrets.NAS_HOST }}:/volume1/homes/admin/nginx-infra/
|
||||
|
||||
- name: Build and push Nginx
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./nginx
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKER_USERNAME }}/robeing-nginx:latest
|
||||
${{ secrets.DOCKER_USERNAME }}/robeing-nginx:${{ github.sha }}
|
||||
|
||||
- name: Update docker-compose.yml
|
||||
run: |
|
||||
sed -i "s|image: .*/robeing-nginx:.*|image: ${{ secrets.DOCKER_USERNAME }}/robeing-nginx:${{ github.sha }}|g" docker-compose.yml
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git add docker-compose.yml
|
||||
git commit -m "Update nginx image to ${{ github.sha }}" || exit 0
|
||||
git push
|
||||
- name: Remote docker-compose up
|
||||
run: |
|
||||
ssh -o StrictHostKeyChecking=no -p ${{ secrets.NAS_PORT }} ${{ secrets.NAS_USER }}@${{ secrets.NAS_HOST }} << 'EOF'
|
||||
cd /volume1/homes/admin/nginx-infra
|
||||
docker-compose up -d --build
|
||||
EOF
|
||||
Loading…
x
Reference in New Issue
Block a user