chore: remove useless code and add comments #49
Workflow file for this run
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: Size report | |
on: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
size-report: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
path: main-code | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 21 | |
- name: Install dependencies | |
working-directory: main-code | |
run: pnpm install | |
- name: Build main branch | |
working-directory: main-code | |
run: pnpm run build | |
- name: Set DIST_PATH environment variable | |
id: set-dist-path | |
working-directory: main-code | |
run: | | |
echo "DIST_PATH=$(pwd)/dist" >> $GITHUB_ENV | |
- name: Checkout PR code | |
uses: actions/checkout@v4 | |
with: | |
path: pr-code | |
- name: Install dependencies | |
working-directory: pr-code | |
run: pnpm install | |
- name: Build PR code | |
working-directory: pr-code | |
run: pnpm run build | |
- name: Calculate size | |
id: calculate-size | |
working-directory: pr-code | |
run: | | |
PREVIOUS_SIZE=$(pnpm tsx scripts/size-report.ts $DIST_PATH) | |
echo "PREVIOUS_SIZE=$PREVIOUS_SIZE" >> $GITHUB_ENV | |
CURRENT_SIZE=$(pnpm tsx scripts/size-report.ts) | |
echo "CURRENT_SIZE=$CURRENT_SIZE" >> $GITHUB_ENV | |
- name: Display size difference | |
run: | | |
echo "Previous Size: $PREVIOUS_SIZE" | |
echo "Current Size: $CURRENT_SIZE" | |
- name: Comment on PR | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const previousSize = process.env.PREVIOUS_SIZE; | |
const currentSize = process.env.CURRENT_SIZE; | |
const message = ` | |
# Size Report | |
| | Build Size | | |
|:-----------:|:---------------:| | |
| Main branch | ${previousSize} | | |
| Current PR | ${currentSize} | | |
`; | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
body: message, | |
}); |