@@ -58,21 +58,25 @@ jobs:
58
58
# Opened/reopened/updated PR: include PR author + title
59
59
- name : " Construct JSON (for PR sync)"
60
60
if : github.event_name == 'pull_request' && github.event.action != 'closed'
61
- # Escape double quotes in PR title, as it will be used in a JSON string .
61
+ # jq escapes backticks, double quotes etc. in PR title .
62
62
run : |
63
- escapedPrTitle=$(echo "${{ github.event.pull_request.title }}" | sed 's/"/\\"/g')
64
- payload=$(cat <<'HEREDOC'
65
- {
63
+ payload=$(jq -n \
64
+ --arg repoOwner '${{ github.repository_owner }}' \
65
+ --arg num '${{ github.event.number }}' \
66
+ --arg commitSha '${{ github.event.pull_request.head.sha }}' \
67
+ --arg date '${{ github.event.pull_request.updated_at }}' \
68
+ --arg prAuthor '${{ github.event.pull_request.user.login }}' \
69
+ --arg prTitle '${{ github.event.pull_request.title }}' \
70
+ '{
66
71
"op": "put",
67
72
"repo": "gdext",
68
- "repo-owner": "${{ github.repository_owner }}",
69
- "num": "${{ github.event.number }}",
70
- "commit-sha": "${{ github.event.pull_request.head.sha }}",
71
- "date": "${{ github.event.pull_request.updated_at }}",
72
- "pr-author": "${{ github.event.pull_request.user.login }}",
73
- "pr-title": "$escapedPrTitle"
74
- }
75
- HEREDOC)
73
+ "repo-owner": $repoOwner,
74
+ "num": $num,
75
+ "commit-sha": $commitSha,
76
+ "date": $date,
77
+ "pr-author": $prAuthor,
78
+ "pr-title": $prTitle
79
+ }')
76
80
echo "VAR=$payload"
77
81
echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV
78
82
echo "${payload}" >> $GITHUB_ENV
0 commit comments