From 10bf3115d2c548fbe85012cfa9a2c2f0d77e6de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Tue, 23 Dec 2025 14:55:29 +0100 Subject: [PATCH] ci: Fix commenting of bundle size (#9539) PR number couldn't be retrieved properly before, so we were never commenting. Move jobs to one file to mitigate it. --- .github/workflows/comment-bundle-size.yaml | 58 ---------------------- .github/workflows/measure-bundle-size.yaml | 42 ++++++++++++++++ 2 files changed, 42 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/comment-bundle-size.yaml diff --git a/.github/workflows/comment-bundle-size.yaml b/.github/workflows/comment-bundle-size.yaml deleted file mode 100644 index 14164de3b..000000000 --- a/.github/workflows/comment-bundle-size.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: Comment Bundle Size - -# Runs when Measure Bundle Size workflow completes. -# This will run with full privileges. -on: - workflow_run: - workflows: [Measure Bundle Size] - types: [completed] - -jobs: - comment: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Download report artifact - uses: actions/download-artifact@v4 - with: - name: bundle-report - path: artifact - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.SHAKA_BOT_TOKEN }} - - - name: Add or Update PR Comment - shell: bash - env: - GITHUB_TOKEN: ${{ secrets.SHAKA_BOT_TOKEN }} - PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} - COMMENT_INCLUDES: "Bundle Size Report" - COMMENT_USER: "shaka-bot" - run: | - if [ -z "$PR_NUMBER" ]; then - echo "No PR found." - exit 0 - fi - - MESSAGE=$(cat artifact/report.md) - echo "$MESSAGE" - - # Find existing bot comment - jq_filter=".[] | select((.user.login == \"$COMMENT_USER\") and (.body | startswith(\"$COMMENT_INCLUDES\"))) | .id" - - gh api \ - /repos/${{ github.repository }}/issues/$PR_NUMBER/comments \ - | jq "$jq_filter" > old-comment-id - - if [[ -z "$(cat old-comment-id)" ]]; then - echo "Creating new bundle size comment" - gh api \ - --method POST \ - /repos/${{ github.repository }}/issues/$PR_NUMBER/comments \ - -f "body=$MESSAGE" - else - echo "Updating existing bundle size comment" - gh api \ - --method PATCH \ - /repos/${{ github.repository }}/issues/comments/$(cat old-comment-id) \ - -f "body=$MESSAGE" - fi diff --git a/.github/workflows/measure-bundle-size.yaml b/.github/workflows/measure-bundle-size.yaml index 593c43338..81d543cae 100644 --- a/.github/workflows/measure-bundle-size.yaml +++ b/.github/workflows/measure-bundle-size.yaml @@ -74,3 +74,45 @@ jobs: name: bundle-report path: report.md retention-days: 1 + + comment: + runs-on: ubuntu-latest + needs: bundle-size + steps: + - name: Download report artifact + uses: actions/download-artifact@v4 + with: + name: bundle-report + path: artifact + + - name: Add or Update PR Comment + shell: bash + env: + GH_TOKEN: ${{ secrets.SHAKA_BOT_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + COMMENT_INCLUDES: "Bundle Size Report" + COMMENT_USER: "shaka-bot" + run: | + MESSAGE=$(cat artifact/report.md) + echo "$MESSAGE" + + # Find existing bot comment + jq_filter=".[] | select((.user.login == \"$COMMENT_USER\") and (.body | startswith(\"$COMMENT_INCLUDES\"))) | .id" + + gh api \ + /repos/${{ github.repository }}/issues/$PR_NUMBER/comments \ + | jq "$jq_filter" > old-comment-id + + if [[ -z "$(cat old-comment-id)" ]]; then + echo "Creating new bundle size comment" + gh api \ + --method POST \ + /repos/${{ github.repository }}/issues/$PR_NUMBER/comments \ + -f "body=$MESSAGE" + else + echo "Updating existing bundle size comment" + gh api \ + --method PATCH \ + /repos/${{ github.repository }}/issues/comments/$(cat old-comment-id) \ + -f "body=$MESSAGE" + fi