Skip to content

TT-17641: document the next-generation plugin compiler #8646

TT-17641: document the next-generation plugin compiler

TT-17641: document the next-generation plugin compiler #8646

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: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.PROBE_APP_ID }}
private-key: ${{ secrets.PROBE_APP_PRIVATE_KEY }}
owner: TykTechnologies
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.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; template passed via env var to keep YAML valid
printf '%s\n' "$PR_TEMPLATE" "$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: ${{ steps.app-token.outputs.token }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_TEMPLATE: |
**πŸ”— 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
cleanup-mirror-pr:
runs-on: ubuntu-latest
if: github.event.action == 'closed'
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.PROBE_APP_ID }}
private-key: ${{ secrets.PROBE_APP_PRIVATE_KEY }}
owner: TykTechnologies
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.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: ${{ steps.app-token.outputs.token }}