Update tib.mdx #3249
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: Mirror PR to production for Preview | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, closed] | ||
| branches: [main] | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| jobs: | ||
| mirror-pr: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.action != 'closed' | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.ORG_GH_TOKEN }} | ||
| - name: Setup GitHub CLI | ||
| run: gh --version | ||
| - name: Create or update mirror PR to production | ||
| run: | | ||
| # Check if mirror PR already exists | ||
| MIRROR_PR=$(gh pr list --base production --head ${{ github.head_ref }} --json number --jq '.[0].number // empty') | ||
| if [ -z "$MIRROR_PR" ]; then | ||
| # Create new mirror PR | ||
| echo "Creating new mirror PR..." | ||
| # Write PR body to file via env var to safely handle special characters | ||
| # (backticks, $, quotes) without shell re-interpretation | ||
| cat > pr_body.txt << 'ENDBODY' | ||
| **π Auto-generated mirror PR for Mintlify preview** | ||
| **Original PR:** #${{ github.event.number }} | ||
| **Author:** @${{ github.event.pull_request.user.login }} | ||
| ## Purpose | ||
| This PR provides a Mintlify preview link for reviewing documentation changes. | ||
| ## Preview Link | ||
| The Mintlify preview will be available once this PR is processed. | ||
| ## β οΈ Important Notes | ||
| - **Do not merge this PR directly** | ||
| - This PR will be auto-merged when the original PR #${{ github.event.number }} is merged | ||
| - Make all comments and reviews on the original PR #${{ github.event.number }} | ||
| ## Changes | ||
| ENDBODY | ||
| printf '%s\n' "$PR_BODY" >> pr_body.txt | ||
| # Escape the title properly to handle special characters and spaces | ||
| ESCAPED_TITLE=$(printf '%s' "π Preview: ${{ github.event.pull_request.title }}" | sed 's/"/\\"/g') | ||
| gh pr create \ | ||
| --base production \ | ||
| --head "${{ github.head_ref }}" \ | ||
| --title "$ESCAPED_TITLE" \ | ||
| --body-file pr_body.txt \ | ||
| --draft | ||
| echo "β Mirror PR created successfully" | ||
| else | ||
| echo "π Mirror PR #$MIRROR_PR already exists and will be auto-updated" | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| cleanup-mirror-pr: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.action == 'closed' | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.ORG_GH_TOKEN }} | ||
| - name: Handle mirror PR when original is closed | ||
| run: | | ||
| # Find the mirror PR | ||
| MIRROR_PR=$(gh pr list --base production --head ${{ github.head_ref }} --json number --jq '.[0].number // empty') | ||
| if [ -n "$MIRROR_PR" ]; then | ||
| if [ "${{ github.event.pull_request.merged }}" = "true" ]; then | ||
| echo "Original PR was merged, closing mirror PR #$MIRROR_PR (no need to merge)..." | ||
| gh pr close $MIRROR_PR | ||
| echo "β Mirror PR #$MIRROR_PR closed" | ||
| else | ||
| echo "Original PR was closed without merging, closing mirror PR #$MIRROR_PR..." | ||
| gh pr close $MIRROR_PR | ||
| echo "β Mirror PR #$MIRROR_PR closed" | ||
| fi | ||
| else | ||
| echo "No mirror PR found for branch ${{ github.head_ref }}" | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }} | ||