diff --git a/.github/workflows/check_db_entities.yml b/.github/workflows/check_db_entities.yml new file mode 100644 index 0000000000..c689b05c38 --- /dev/null +++ b/.github/workflows/check_db_entities.yml @@ -0,0 +1,77 @@ +name: check_db_entities + +on: + pull_request: + paths: + - 'packages/stream_chat_persistence/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check_entity_modifications: + runs-on: ubuntu-latest + steps: + - name: 📥 Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: 🔎 Check DB Entity Changes + id: check_entities + run: | + ENTITY_DIR="packages/stream_chat_persistence/lib/src/entity" + TEMP_FILE="modified_entities" + BASE_BRANCH="${{ github.base_ref }}" + + echo "Using base branch: origin/$BASE_BRANCH for comparison" + + # Check if any entity files have changed compared to the base branch + git diff-index --name-only origin/$BASE_BRANCH -- $ENTITY_DIR | grep -E '\.dart$' > $TEMP_FILE || true + + if [ ! -s "$TEMP_FILE" ]; then + echo "✅ No entity files changed." + echo "has_changes=false" >> $GITHUB_OUTPUT + rm $TEMP_FILE + exit 0 + fi + + echo "⚠️ Entity files modified:" + cat $TEMP_FILE + + # Set modified files as output + echo "modified_files<> $GITHUB_OUTPUT + cat $TEMP_FILE >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + echo "has_changes=true" >> $GITHUB_OUTPUT + + - name: 🔍 Find Comment + if: steps.check_entities.outputs.has_changes == 'true' + uses: peter-evans/find-comment@v2 + id: find_comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: github-actions[bot] + body-includes: Database Entity Files Modified + + - name: 💬 Create or Update Comment + if: steps.check_entities.outputs.has_changes == 'true' + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.find_comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## ⚠️ Database Entity Files Modified + + The following database entity files have been modified in this PR: + ``` + ${{ steps.check_entities.outputs.modified_files }} + ``` + + ### 📝 Remember to: + 1. Update database version in `db/drift_chat_database.dart`. + 2. Update entity schema tests if necessary. + + *Note: This comment is automatically generated by the CI workflow.* + edit-mode: replace \ No newline at end of file