Skip to content

Added tracking for Typesense to posthog #1022

Added tracking for Typesense to posthog

Added tracking for Typesense to posthog #1022

# If this workflow failed in your PR, run `pre-commit install` and commit your files again.
# See instructions in the README.md in the repo root for more details.
name: Run pre-commit to check that formatting is correct
on:
pull_request:
jobs:
pre_commit:
name: "pre-commit"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6.0.0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # ratchet:actions/setup-python@v6.0.0
with:
python-version: "3.14"
cache: "pip"
# Only run it on changed files with: https://github.com/pre-commit/action/issues/7
- id: changed-files
uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # ratchet:tj-actions/changed-files@v47
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # ratchet:pre-commit/action@v3.0.1
id: pre-commit
continue-on-error: true
with:
extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }}
# Capture the diff of proposed changes
- name: Get proposed changes
if: steps.pre-commit.outcome == 'failure' && github.event_name == 'pull_request'
id: get-diff
run: |
# Get the diff of changes that pre-commit would make
git diff > proposed-changes.diff
# Check if there are actual changes
if [ -s proposed-changes.diff ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
# Store diff for use in the next step, escaping for JSON
DIFF_CONTENT=$(cat proposed-changes.diff)
echo "diff_content<<EOF" >> $GITHUB_OUTPUT
echo "$DIFF_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
# Post proposed changes as review comments with suggestions
- name: Post proposed changes
if: steps.get-diff.outputs.has_changes == 'true' && github.event_name == 'pull_request'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ratchet:actions/github-script@v8.0.0
env:
DIFF_CONTENT: ${{ steps.get-diff.outputs.diff_content }}
with:
script: |
const script = require('./.github/scripts/post-precommit-suggestions.js');
await script({ github, context, diff: process.env.DIFF_CONTENT });