Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: version one of workflow to check added resolution #8800

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/check-resolutions-added.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check Package Resolutions for Additions

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-package-resolutions-for-additions:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn

- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Check for resolutions additions
run: |
# Fetch the base branch (e.g., main) package.json and rename it to package-base.json
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
git checkout ${{ github.base_ref }} -- package.json
mv package.json package-base.json

# Checkout back to the PR branch
git checkout -- package.json

# Use jq to compare resolutions field in base and PR branch package.json files
# Count resolutions in base and PR branch package.json
BASE_COUNT=$(jq '.resolutions | length' package-base.json)
PR_COUNT=$(jq '.resolutions | length' package.json)

# If the PR branch has more resolutions, fail the check
if [ "$PR_COUNT" -gt "$BASE_COUNT" ]; then
echo "Adding new resolutions to package.json is not allowed."
exit 1
fi
Loading