Skip to content

Commit 9c4ef7f

Browse files
[fix] Prevent JavaScript syntax errors in sync workflow (#41)
Uses environment variables instead of template literals to avoid conflicts with special characters in PR titles, RFC content, and other GitHub Actions expressions
1 parent ef51d45 commit 9c4ef7f

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

.github/workflows/sync-rfc-discussion.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,36 @@ jobs:
8989
- name: Update Discussion Content
9090
if: steps.find-discussion.outputs.discussion_id && steps.changed-files.outputs.filename
9191
uses: actions/github-script@v7
92+
env:
93+
DISCUSSION_ID: ${{ steps.find-discussion.outputs.discussion_id }}
94+
RFC_CONTENT: ${{ steps.get-rfc-content.outputs.content }}
95+
MD_FILE: ${{ steps.changed-files.outputs.filename }}
96+
PR_TITLE: ${{ github.event.pull_request.title }}
97+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
98+
PR_NUMBER: ${{ github.event.pull_request.number }}
99+
PR_URL: ${{ github.event.pull_request.html_url }}
100+
REPO_NAME: ${{ github.repository }}
101+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
102+
UPDATED_AT: ${{ github.event.pull_request.updated_at }}
103+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
104+
HEAD_REPO_URL: ${{ github.event.pull_request.head.repo.html_url }}
92105
with:
93106
script: |
94-
const discussionId = '${{ steps.find-discussion.outputs.discussion_id }}';
95-
const rfcContent = '${{ steps.get-rfc-content.outputs.content }}';
96-
const mdFile = '${{ steps.changed-files.outputs.filename }}';
107+
const discussionId = process.env.DISCUSSION_ID;
108+
const rfcContent = process.env.RFC_CONTENT;
109+
const mdFile = process.env.MD_FILE;
97110
98111
// Build the body content parts
99-
const title = `# RFC Discussion: ${{ github.event.pull_request.title }}`;
100-
const author = `**Author:** @${{ github.event.pull_request.user.login }} | **Status:** 🟡 Under Review`;
112+
const title = `# RFC Discussion: ${process.env.PR_TITLE}`;
113+
const author = `**Author:** @${process.env.PR_AUTHOR} | **Status:** 🟡 Under Review`;
101114
const links = `## 📋 Quick Links
102-
- 🔧 [Source PR #${{ github.event.pull_request.number }}](${{ github.event.pull_request.html_url }})
103-
- 📝 [View Changes](${{ github.event.pull_request.html_url }}/files)
104-
- 📖 [Rendered Proposal](https://github.com/${{ github.repository }}/blob/${{ github.event.pull_request.head.ref }}/${mdFile})`;
115+
- 🔧 [Source PR #${process.env.PR_NUMBER}](${process.env.PR_URL})
116+
- 📝 [View Changes](${process.env.PR_URL}/files)
117+
- 📖 [Rendered Proposal](https://github.com/${process.env.REPO_NAME}/blob/${process.env.HEAD_REF}/${mdFile})`;
105118
106119
const proposalHeader = `## 📄 Current Proposal`;
107-
const metadata = `> **Last Updated:** ${{ github.event.pull_request.updated_at }}
108-
> **Commit:** [\`${{ github.event.pull_request.head.sha }}\`](${{ github.event.pull_request.head.repo.html_url }}/commit/${{ github.event.pull_request.head.sha }})`;
120+
const metadata = `> **Last Updated:** ${process.env.UPDATED_AT}
121+
> **Commit:** [\`${process.env.HEAD_SHA}\`](${process.env.HEAD_REPO_URL}/commit/${process.env.HEAD_SHA})`;
109122
110123
const guidelines = `**💬 Discussion Guidelines:** Share feedback, concerns, and suggestions below. Use reply threads to keep conversations organized.`;
111124

0 commit comments

Comments
 (0)