Skip to content

Commit 63ba60a

Browse files
sharadregoticlaude
andcommitted
Fix mirror-pr workflow failing on PR bodies with special characters
GitHub Actions expands ${{ }} expressions before the shell runs, so backticks and $ signs in PR bodies were injected raw into the script and interpreted as shell command substitution. Fix: write static content via a single-quoted heredoc (no shell expansion), then append the PR body via printf with an env var ($PR_BODY). Shell variables accessed as "$VAR" are never re-interpreted, making any PR body content safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1ab742e commit 63ba60a

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

.github/workflows/mirror-pr-to-build-deploy.yml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,28 @@ jobs:
3232
# Create new mirror PR
3333
echo "Creating new mirror PR..."
3434
35-
# Create PR body content using printf to avoid shell parsing issues
36-
printf '%s\n' \
37-
"**🔗 Auto-generated mirror PR for Mintlify preview**" \
38-
"" \
39-
"**Original PR:** #${{ github.event.number }}" \
40-
"**Author:** @${{ github.event.pull_request.user.login }}" \
41-
"" \
42-
"## Purpose" \
43-
"This PR provides a Mintlify preview link for reviewing documentation changes." \
44-
"" \
45-
"## Preview Link" \
46-
"The Mintlify preview will be available once this PR is processed." \
47-
"" \
48-
"## ⚠️ Important Notes" \
49-
"- **Do not merge this PR directly**" \
50-
"- This PR will be auto-merged when the original PR #${{ github.event.number }} is merged" \
51-
"- Make all comments and reviews on the original PR #${{ github.event.number }}" \
52-
"" \
53-
"## Changes" \
54-
"${{ github.event.pull_request.body }}" > pr_body.txt
35+
# Write PR body to file via env var to safely handle special characters
36+
# (backticks, $, quotes) without shell re-interpretation
37+
cat > pr_body.txt << 'ENDBODY'
38+
**🔗 Auto-generated mirror PR for Mintlify preview**
39+
40+
**Original PR:** #${{ github.event.number }}
41+
**Author:** @${{ github.event.pull_request.user.login }}
42+
43+
## Purpose
44+
This PR provides a Mintlify preview link for reviewing documentation changes.
45+
46+
## Preview Link
47+
The Mintlify preview will be available once this PR is processed.
48+
49+
## ⚠️ Important Notes
50+
- **Do not merge this PR directly**
51+
- This PR will be auto-merged when the original PR #${{ github.event.number }} is merged
52+
- Make all comments and reviews on the original PR #${{ github.event.number }}
53+
54+
## Changes
55+
ENDBODY
56+
printf '%s\n' "$PR_BODY" >> pr_body.txt
5557

5658
# Escape the title properly to handle special characters and spaces
5759
ESCAPED_TITLE=$(printf '%s' "🔄 Preview: ${{ github.event.pull_request.title }}" | sed 's/"/\\"/g')
@@ -69,6 +71,7 @@ jobs:
6971
fi
7072
env:
7173
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
74+
PR_BODY: ${{ github.event.pull_request.body }}
7275

7376
cleanup-mirror-pr:
7477
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)