name: Deploy to Server run-name: Deploying to ${{ runner.os}} server on ${{ gitea.ref }} on: push: branches: - main - ci/gitea-actions jobs: deploy: runs-on: prod steps: - name: Fetch and Diff Analysis id: diff run: | cd ${{ secrets.PROD_DIR }} git fetch origin main CHANGES=$(git diff --name-only HEAD origin/main | cut -d/ -f1 | sort -u | tr '\n' ' ') echo "dirs=$CHANGES" >> $GITHUB_OUTPUT echo "Changed dirs: $CHANGES" - name: Sync Server Files run: | cd ${{ secrets.PROD_DIR }} git reset --hard origin/main echo "Server files synced with origin/main" - name: Deploy Services run: | cd ${{ secrets.PROD_DIR }} for dir in ${{ steps.diff.outputs.dirs }}; do if [ -d "$dir" ] && ([ -f "$dir/compose.yaml" ] || [ -f "$dir/docker-compose.yaml" ]); then echo ">>> Deploying $dir" cd "$dir" docker compose up -d --build cd .. else echo ">>> Skipping $dir: no compose file found" fi done