Skip to content

Commit

Permalink
CI/pr-size: Use pull_request_target to get write permission
Browse files Browse the repository at this point in the history
- Build and use pr-size from the base branch
- Compare against the PR in a second step
  • Loading branch information
wavexx committed Aug 4, 2023
1 parent 18dc28b commit b9381d5
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/pr-size.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pr-size

on:
pull_request:
pull_request_target:
branches: [ MK3, MK3_* ]

env:
Expand All @@ -10,6 +10,8 @@ env:
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:

Expand All @@ -18,47 +20,47 @@ jobs:
run: |
sudo apt-get install cmake ninja-build python3-pyelftools python3-regex python3-polib
# build the PR branch
- name: Checkout PR
# build the base branch
- name: Checkout base
uses: actions/checkout@v3

- name: Setup build dependencies
run: |
./utils/bootstrap.py
- name: Build PR
- name: Build base
run: |
rm -rf build-pr
mkdir build-pr
cd build-pr
rm -rf build-base
mkdir build-base
cd build-base
cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja
ninja $TARGETS
# save pr-size for later use
- name: Save pr-size from PR
- name: Save base data
run: |
cp -f ./.github/workflows/pr-size.sh build-pr
cp -f ./.github/workflows/pr-size.sh build-base
# build the base branch
- name: Checkout base
# build the PR branch
- name: Checkout PR
uses: actions/checkout@v3
with:
clean: false
ref: ${{ github.event.pull_request.base.ref }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Build base
- name: Build PR
run: |
rm -rf build-base
mkdir build-base
cd build-base
rm -rf build-pr
mkdir build-pr
cd build-pr
cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja
ninja $TARGETS
# extract/show build differences
- name: Calculate binary changes
run: |
rm -rf build-changes
./build-pr/pr-size.sh build-changes build-base build-pr $TARGETS
./build-base/pr-size.sh build-changes build-base build-pr $TARGETS
- name: Add PR Comment
uses: mshick/add-pr-comment@v2
Expand Down

0 comments on commit b9381d5

Please sign in to comment.