name: Forward public PR to private
on:
pull_request_target:
types: [labeled]
jobs:
forward:
# Run only if the PR currently has the label
if: github.event.label.name == 'auto-merge'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Dispatch to private repo
env:
TOKEN: ${{ secrets.PR_SYNC_TOKEN }} # PAT with repo scope on the *private* repo
PRIVATE_REPO: TheLunarCompany/lunar-private
run: |
cat > /tmp/payload.json <<'JSON'
{
"event_type": "forward-public-pr",
"client_payload": {
"number": ${{ github.event.pull_request.number }},
"base_repo_full_name": "${{ github.repository }}",
"head_repo_full_name": "${{ github.event.pull_request.head.repo.full_name }}",
"head_ref": "${{ github.event.pull_request.head.ref }}",
"head_sha": "${{ github.event.pull_request.head.sha }}",
"title": ${{ toJSON(github.event.pull_request.title) }},
"body": ${{ toJSON(github.event.pull_request.body || '') }},
"html_url": "${{ github.event.pull_request.html_url }}",
"sender": "${{ github.event.pull_request.user.login }}",
"sender_id": ${{ github.event.pull_request.user.id }}
}
}
JSON
curl -sS -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github+json" \
-X POST "https://api.github.com/repos/$PRIVATE_REPO/dispatches" \
--data @/tmp/payload.json