Skip to content

Commit

Permalink
Fixup: use jq
Browse files Browse the repository at this point in the history
  • Loading branch information
elsom25 committed May 2, 2024
1 parent 5e7f760 commit 19e673a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ensure_dist_committed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ jobs:
- name: Inform PR author of failure and path to fix
if: ${{ failure() && steps.ensure-dist-committed.outcome == 'failure' }}
run: |
# Using GitHub API to create a comment on the PR
COMMENT="Hi there! It looks like your pull request includes changes to distribution files that haven't been committed. To keep our repository clean, could you please commit these changes? Alternatively, you can also use the command \\\`/generate_dist\\\` in a comment here, and I'll take care of committing these changes for you 😊. This helps ensure that our main branch remains stable and build-ready at all times. Thanks for contributing!"
# Comment to send
COMMENT="Hi there! It looks like your pull request changes taxonomy \`data/*\` files, but is missing updates to \`dist/*\` files.\n\n**⏭️ How to fix**\n\nThe command \`/generate_dist\` will fix this for you. Alternatively, you can run \`make\` locally and commit the changes yourself."
# GitHub API Token and PR URL
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST "$COMMENT_URL" -d "{\"body\":\"$COMMENT\"}"
# Use jq to encode the JSON properly, carefully handling the new lines and backticks
JSON_BODY=$(jq -n --arg body "$COMMENT" '{body: $body}')
# Use curl to post the comment.
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST "$COMMENT_URL" -d "$JSON_BODY"

0 comments on commit 19e673a

Please sign in to comment.