Skip to content
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
84 changes: 84 additions & 0 deletions .github/workflows/sync-rush-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Sync Rush.json Version
on:
pull_request:
types: [opened, synchronize]
paths:
- "**/package.json"
- "rush.json"
- "common-versions.json"

permissions:
contents: write
pull-requests: write

jobs:
detect:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
outputs:
rush_changed: ${{ steps.detect.outputs.rush_changed }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2 # Fetch current commit + previous commit
- name: Detect Rush bump
id: detect
run: |
# Look for @microsoft/rush in the diff
if git diff -U0 HEAD~1 -- package.json | grep '"@microsoft/rush"'; then
echo "rush_changed=true" >> $GITHUB_OUTPUT
echo "Rush change detected"
else
echo "rush_changed=false" >> $GITHUB_OUTPUT
echo "No Rush change detected"
fi

update:
runs-on: ubuntu-latest
needs: detect
if: needs.detect.outputs.rush_changed == 'true'
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20

- name: Install Rush
run: npm install -g @microsoft/rush

- name: Sync rush.json
run: |
echo "Syncing rush.json with Dependabot bump..."
# Extract new Rush version from package.json
NEW_VERSION=$(jq -r '.devDependencies["@microsoft/rush"] // .dependencies["@microsoft/rush"]' package.json)

# Update rush.json version field
jq ".rushVersion = \"$NEW_VERSION\"" rush.json > rush.tmp.json
mv rush.tmp.json rush.json

- name: Run rush update
run: |
rush update --full

- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Add files that exist
if [ -f rush.json ]; then git add rush.json; fi
if [ -f common-versions.json ]; then git add common-versions.json; fi
if [ -f common/config/rush/npm-shrinkwrap.json ]; then git add common/config/rush/npm-shrinkwrap.json; fi
# Add all changes in common/scripts folder if it exists
if [ -d common/scripts ]; then git add common/scripts/; fi
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "chore: sync rush.json and regenerate lockfiles"
git push
fi
Loading