73 lines
2.5 KiB
YAML
73 lines
2.5 KiB
YAML
name: Bundle Size Comment
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Check"]
|
|
types:
|
|
- completed
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
comment:
|
|
name: Bundle
|
|
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: read
|
|
pull-requests: write
|
|
timeout-minutes: 1
|
|
steps:
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: bundle-stats
|
|
path: bundle-stats
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Get stats
|
|
id: stats
|
|
run: |
|
|
{
|
|
echo 'stats<<EOF'
|
|
cat bundle-stats/stats.txt
|
|
echo EOF
|
|
} >> $GITHUB_OUTPUT
|
|
# https://github.com/orgs/community/discussions/25220#discussioncomment-11300118
|
|
- name: Get PR number
|
|
id: pr-context
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_TARGET_REPO: ${{ github.repository }}
|
|
PR_BRANCH: |-
|
|
${{
|
|
(github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
|
|
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
|
|
|| github.event.workflow_run.head_branch
|
|
}}
|
|
run: gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" --json 'number' --jq '"number=\(.number)"' >> "${GITHUB_OUTPUT}"
|
|
- name: Find Comment
|
|
id: find-comment
|
|
uses: peter-evans/find-comment@v4
|
|
with:
|
|
issue-number: ${{ steps.pr-context.outputs.number }}
|
|
comment-author: "github-actions[bot]"
|
|
body-includes: <!-- This comment was auto-generated by GitHub Actions to display bundle size statistics -->
|
|
- name: Create Comment
|
|
id: comment
|
|
uses: peter-evans/create-or-update-comment@v5
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
BUNDLE_STATS: "${{ steps.stats.outputs.stats }}"
|
|
with:
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
|
issue-number: ${{ steps.pr-context.outputs.number }}
|
|
edit-mode: replace
|
|
body: |
|
|
<!-- This comment was auto-generated by GitHub Actions to display bundle size statistics -->
|
|
## Bundle Size Analysis
|
|
${{ env.BUNDLE_STATS }}
|