Skip to content

Prevent PublicAPI File Additions using a workflow #2

Prevent PublicAPI File Additions using a workflow

Prevent PublicAPI File Additions using a workflow #2

name: Prevent PublicAPI File Additions
on: [pull_request]
jobs:
check-publicapi-files:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Scan for accidental PublicAPI references
run: |
set -e # Stop on first error
# Find all .csproj files and check for unwanted lines
if find . -name "*.csproj" -exec grep -q "PublicAPI.Shipped.txt" {} \; || \
find . -name "*.csproj" -exec grep -q "PublicAPI.Unshipped.txt" {} \;
then
echo "Error: PublicAPI.Shipped.txt or PublicAPI.Unshipped.txt detected in a .csproj file."
exit 1
fi
echo "All good - No PublicAPI references found."