Post Comment to PR #364
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Post Comment to PR | |
on: | |
workflow_run: | |
workflows: ["on PR action"] | |
types: | |
- completed | |
jobs: | |
create_comment_with_memory_usage: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
contents: read | |
checks: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get artifacts from PR | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
run_id: ${{github.event.workflow_run.id}} | |
path: current | |
- name: Get artifacts from PR base | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
commit: ${{github.event.workflow_run.event.pull_request.base.sha}} | |
workflow: on-commit.yml | |
path: old | |
- name: Unpack PR number | |
id: get-pr-number | |
run: | | |
pr_number="$(cat current/PR_number/PR_number)" | |
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT | |
- name: Generage memory diff | |
run: | | |
shopt -s extglob | |
pr_reports=$(ls current/sample-artifacts/subsets/*/twister.json) | |
python3 scripts/ci/combine_twister_reports.py $pr_reports new.json | |
base_reports=$(ls old/sample-artifacts/subsets/*/twister.json) | |
python3 scripts/ci/combine_twister_reports.py $base_reports old.json | |
python3 scripts/ci/compare_size_reports.py -o old.json -n new.json --md_output --show_only_diff > memory_usage.md | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ steps.get-pr-number.outputs.pr_number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: "| Sample | | diff | used | total |" | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ steps.get-pr-number.outputs.pr_number }} | |
body-path: memory_usage.md | |
edit-mode: replace |