Skip to content

Commit

Permalink
ci: fix check-pr workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 12, 2024
1 parent 857e252 commit 57951b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
run: echo "$PR_TITLE" | pnpm -s dlx [email protected]
- name: Refresh Bundle Impact
uses: actions/github-script@v6
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
23 changes: 10 additions & 13 deletions scripts/weigh-changed.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
set -e

# DEBUG (remove this)
git branch -vv
git remote -vv

# Try using gh to get the target branch, otherwise use 'main' as a fallback.
TARGET_BRANCH=$(which gh > /dev/null 2>&1 && gh pr view --json baseRefName --jq .baseRefName || echo "")
echo "TARGET_BRANCH => $TARGET_BRANCH"
TARGET_BRANCH=${TARGET_BRANCH:-main}
if [[ -z "$TARGET_BRANCH" ]]; then
TARGET_BRANCH=$(which gh > /dev/null 2>&1 && gh pr view --json baseRefName --jq .baseRefName 2> /dev/null || echo "")
TARGET_BRANCH=${TARGET_BRANCH:-main}
fi

# Get the list of changed source files relative to the target branch.
CHANGES=$(git diff --name-status "origin/$TARGET_BRANCH" HEAD -- 'src/*/*.ts')
Expand Down Expand Up @@ -73,11 +70,11 @@ fi

if [[ -n "$CI" ]]; then
if [ "$column_count" -gt 2 ]; then
echo "| File | Size | Difference (%) |"
echo "|---|---|---|"
echo "| Status | File | Size | Difference (%) |"
echo "|---|---|---|---|"
else
echo "| File | Size |"
echo "|---|---|"
echo "| Status | File | Size |"
echo "|---|---|---|"
fi
fi

Expand Down Expand Up @@ -108,9 +105,9 @@ for file in "${FILE_NAMES[@]}"; do

if [[ -n "$CI" ]]; then
if [ "$column_count" -gt 2 ]; then
echo "| $file | $bytes | $diff$ratio |"
echo "| $status | \`$file\` | $bytes | $diff$ratio |"
else
echo "| $file | $bytes |"
echo "| $status | \`$file\` | $bytes |"
fi
else
if [ "$column_count" -gt 2 ] && [ "$prev_bytes" -ne 0 ]; then
Expand Down

0 comments on commit 57951b4

Please sign in to comment.