Skip to content

Commit

Permalink
Doc sync improvements
Browse files Browse the repository at this point in the history
Escape PR titles using jq, add repo-owner (to avoid forks pushing docs)
  • Loading branch information
Bromeon committed Nov 22, 2023
1 parent ac5f133 commit 83ca5c2
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
{
"op": "put",
"repo": "gdnative",
"repo-owner": "${{ github.repository_owner }}",
"num": "master",
"commit-sha": "${{ github.sha }}",
"date": "${{ github.event.head_commit.timestamp }}"
Expand All @@ -52,18 +53,25 @@ jobs:
# Opened/reopened/updated PR: include PR author + title
- name: "Construct JSON (for PR sync)"
if: github.event_name == 'pull_request' && github.event.action != 'closed'
# jq escapes backticks, double quotes etc. in PR title.
run: |
payload=$(cat <<'HEREDOC'
{
payload=$(jq -n \
--arg repoOwner '${{ github.repository_owner }}' \
--arg num '${{ github.event.number }}' \
--arg commitSha '${{ github.event.pull_request.head.sha }}' \
--arg date '${{ github.event.pull_request.updated_at }}' \
--arg prAuthor '${{ github.event.pull_request.user.login }}' \
--arg prTitle '${{ github.event.pull_request.title }}' \
'{
"op": "put",
"repo": "gdnative",
"num": "${{ github.event.number }}",
"commit-sha": "${{ github.event.pull_request.head.sha }}",
"date": "${{ github.event.pull_request.updated_at }}",
"pr-author": "${{ github.event.pull_request.user.login }}",
"pr-title": "${{ github.event.pull_request.title }}"
}
HEREDOC)
"repo-owner": $repoOwner,
"num": $num,
"commit-sha": $commitSha,
"date": $date,
"pr-author": $prAuthor,
"pr-title": $prTitle
}')
echo "VAR=$payload"
echo "GDNATIVE_JSON<<HEREDOC" >> $GITHUB_ENV
echo "${payload}" >> $GITHUB_ENV
Expand All @@ -77,6 +85,7 @@ jobs:
{
"op": "delete",
"repo": "gdnative",
"repo-owner": "${{ github.repository_owner }}",
"num": "${{ github.event.number }}",
"date": "${{ github.event.pull_request.updated_at }}"
}
Expand Down

0 comments on commit 83ca5c2

Please sign in to comment.