-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add workflow to sync Rush.json version on PR #326
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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" | ||
|
|
||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 }} | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fetch-depth: 0 | ||
| ref: ${{ github.head_ref }} | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v6 | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install Rush | ||
| run: npm install -g @microsoft/rush | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mv rush.tmp.json rush.json | ||
|
|
||
| - name: Run rush update | ||
| run: | | ||
| rush update --full | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
nev21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.