Skip to content

Fix: TS & Py versions for log pagination (#2505) #227

Fix: TS & Py versions for log pagination (#2505)

Fix: TS & Py versions for log pagination (#2505) #227

Workflow file for this run

name: generate examples
on:
push:
branches: [ main ]
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Generate snippets
working-directory: frontend/snippets
run: python3 generate.py
- name: Check for changes in examples directory
id: verify-changed-files
run: |
# Check if there are any changes
if [ -n "$(git status --porcelain)" ]; then
CHANGED_FILES=$(git status --porcelain | awk '{print $2}')
NON_EXAMPLES_CHANGES=$(echo "$CHANGED_FILES" | grep -v "^examples/" || true)
if [ -n "$NON_EXAMPLES_CHANGES" ]; then
echo "Error: Changes detected outside of examples directory:"
echo "$NON_EXAMPLES_CHANGES"
echo "changed=false" >> $GITHUB_OUTPUT
exit 1
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Create branch and commit changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
BRANCH_NAME="regenerate-examples-${{ github.sha }}"
git checkout -b "$BRANCH_NAME"
git add examples/
git commit -m "chore: regenerate examples"
git push origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
id: create-branch
- name: Close existing autogenerated-docs PRs
if: steps.verify-changed-files.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING_PRS=$(gh pr list --label "autogenerated-docs" --state open --json number --jq '.[].number')
for pr in $EXISTING_PRS; do
if [ -n "$pr" ]; then
echo "Closing existing autogenerated-docs PR #$pr"
gh pr close $pr --comment "Closing in favor of newer autogenerated-docs PR"
fi
done
- name: Create Pull Request
if: steps.verify-changed-files.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "chore: regenerate examples" \
--body "Automated regeneration of examples from the main branch." \
--head "${{ steps.create-branch.outputs.branch_name }}" \
--base main \
--label "autogenerated-docs"
echo "pr_number=$(gh pr list --head ${{ steps.create-branch.outputs.branch_name }} --json number --jq '.[0].number')" >> $GITHUB_OUTPUT
id: create-pr
- name: Request review from triggering author
if: steps.verify-changed-files.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
AUTHOR="${{ github.actor }}"
if [ "$AUTHOR" != "github-actions[bot]" ]; then
gh pr edit "${{ steps.create-branch.outputs.branch_name }}" --add-reviewer "$AUTHOR" || {
gh pr comment "${{ steps.create-branch.outputs.branch_name }}" --body "@$AUTHOR Please review this autogenerated PR"
}
echo "Requested review from $AUTHOR"
else
echo "Skipping review request as author is github-actions bot"
fi