fix: Python SDK worker heartbeat should not stop until in-flight task… #1243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: generate examples | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Install Task | |
| uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version: "1.26" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 | |
| with: | |
| version: 10.16.1 | |
| run_install: false | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: "3.14" | |
| - name: Generate snippets | |
| run: task install-dependencies pre-commit-install generate-docs -v | |
| - 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/" | grep -v "^frontend/docs/pages/reference/changelog/" || 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 "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| BRANCH_NAME="regenerate-examples-${{ github.sha }}" | |
| git checkout -b "$BRANCH_NAME" | |
| git add -u && 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 |