From 239e143434456c47abdf66f4f9be7d86358cae78 Mon Sep 17 00:00:00 2001 From: Adam Crawford Date: Sat, 21 Feb 2026 13:56:35 -0500 Subject: [PATCH 1/2] feat: Conditionally apply Docker Compose changes by parsing rsync output for actual file transfers or manual workflow dispatch. --- .github/workflows/deploy-prod.yaml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index 7ab1a31..d1de8bd 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -157,16 +157,30 @@ jobs: fi - name: Sync configuration files + id: sync run: | echo "Syncing repository contents to ${{ secrets.DOCKER_DIR }}" - sudo rsync -av --no-o --no-g --checksum \ + # Use --itemize-changes (-i) and capture output to a file to determine if actual transfers occurred + sudo rsync -avi --no-o --no-g --checksum \ "$GITHUB_WORKSPACE/docker/" \ "${{ secrets.DOCKER_DIR }}/" \ --exclude ".git/" \ --exclude ".github/" \ --exclude "*.sops.env" \ --exclude "prometheus/config/prometheus.yml.template" \ - --exclude "unbound/unbound.conf.template" + --exclude "unbound/unbound.conf.template" > rsync_output.txt + + cat rsync_output.txt + + # Check if rsync_output.txt contains lines starting with '<', '>', or 'c' which indicate file updates/transfers + # Lines starting with '.' mean no change. Lines starting with '*' are usually messages/directories + if grep -E "^[]|^>f" rsync_output.txt > /dev/null; then + echo "Files were updated during sync." + echo "files_changed=true" >> "$GITHUB_OUTPUT" + else + echo "No files were updated during sync." + echo "files_changed=false" >> "$GITHUB_OUTPUT" + fi - name: Navigate to Docker Compose directory run: cd "${{ secrets.DOCKER_DIR }}" @@ -179,8 +193,10 @@ jobs: password: ${{ secrets.DOCKER_PAT }} - name: Apply Docker Compose changes + if: steps.sync.outputs.files_changed == 'true' || github.event_name == 'workflow_dispatch' run: | cd "${{ secrets.DOCKER_DIR }}" + echo "Changes detected or manual run forced. Applying Docker Compose..." sudo docker compose up -d --remove-orphans - name: Prune unused Docker images From 2a508c0ada7e6e5a5fe3210689436fba6c486791 Mon Sep 17 00:00:00 2001 From: Adam Crawford Date: Sat, 21 Feb 2026 13:59:45 -0500 Subject: [PATCH 2/2] fix: only apply Docker Compose changes when files are modified, removing `workflow_dispatch` as a forced trigger. --- .github/workflows/deploy-prod.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index d1de8bd..cd3a609 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -193,10 +193,10 @@ jobs: password: ${{ secrets.DOCKER_PAT }} - name: Apply Docker Compose changes - if: steps.sync.outputs.files_changed == 'true' || github.event_name == 'workflow_dispatch' + if: steps.sync.outputs.files_changed == 'true' run: | cd "${{ secrets.DOCKER_DIR }}" - echo "Changes detected or manual run forced. Applying Docker Compose..." + echo "Changes detected. Applying Docker Compose..." sudo docker compose up -d --remove-orphans - name: Prune unused Docker images