Skip to content

Commit

Permalink
next step
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Aug 5, 2023
1 parent 21aac46 commit f0f8475
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 55 deletions.
36 changes: 30 additions & 6 deletions .github/workflows/check-type-sizes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,41 @@ jobs:
--reports $(find reports -name '*.json') \
--template tools/type-size-comment.md.in \
--output tools/type-size-comment.md \
--github-actions
- name: Generate artifact
--github-actions >num_rows.txt
echo rows=$(cat num_rows.txt) >> $GITHUB_OUTPUT
- name: Generate comment data
run: |
jq --null-input \
--rawfile comment tools/type-size-comment.md \
--arg comment_search "<!--type-size-comment-->" \
--arg pr_number "${{ github.event.pull_request.number }}" \
--arg rows "${{ steps.generate_comment.outputs.rows }}" \
'{$comment, $comment_search, $pr_number, update_only:($rows|tonumber <= 0)}' > comment-info.json
- name: Upload artifact
uses: actions/upload-artifact@v3
- name: Format comment
id: format
run: |
set -ex
body="$(jq --raw-output .comment comment-info.json)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
echo "COMMENT_SEARCH=$(jq --raw-output .comment_search comment-info.json)" >> $GITHUB_ENV
echo "COMMENT_PR_NUMBER=$(jq --raw-output .pr_number comment-info.json)" >> $GITHUB_ENV
echo "COMMENT_UPDATE_ONLY=$(jq --raw-output 'if .update_only then 1 else 0 end' comment-info.json)" >> $GITHUB_ENV
- name: Find existing comment
id: find_comment
uses: peter-evans/find-comment@v1
with:
issue-number: ${{ env.COMMENT_PR_NUMBER }}
comment-author: github-actions[bot]
body-includes: ${{ env.COMMENT_SEARCH }}
- name: Post comment
if: ${{ env.COMMENT_UPDATE_ONLY != 1 || steps.find_comment.outputs.comment-id != '' }}
uses: peter-evans/create-or-update-comment@v1
with:
name: comment-info.json
path: comment-info.json
issue-number: ${{ env.COMMENT_PR_NUMBER }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: ${{ steps.format.outputs.body }}
edit-mode: replace
48 changes: 0 additions & 48 deletions .github/workflows/comment-pr.yml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/generate-type-size-comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
f.write(template.render(rows=rows))

if args.github_actions:
print("::set-output name=rows::%s" % len(rows))
print("%s" % len(rows))

0 comments on commit f0f8475

Please sign in to comment.