Skip to content

Nx migrate

Nx migrate #11

Workflow file for this run

name: Nx migrate
on:
schedule:
- cron: '0 6 * * *' # Every night at 06:00 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: lts/*
cache: 'npm'
- name: Check for newer Nx version
id: check
run: |
current=$(node -p "require('./package.json').devDependencies.nx")
latest=$(npm view nx version)
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "latest=$latest" >> "$GITHUB_OUTPUT"
if [ "$current" = "$latest" ]; then
echo "up_to_date=true" >> "$GITHUB_OUTPUT"
echo "Already on latest Nx version ($current)."
else
echo "up_to_date=false" >> "$GITHUB_OUTPUT"
echo "Nx update available: $current -> $latest"
fi
- name: Install dependencies
if: steps.check.outputs.up_to_date == 'false'
run: npm install
- name: Run nx migrate
if: steps.check.outputs.up_to_date == 'false'
run: npx nx migrate latest
- name: Install updated dependencies
if: steps.check.outputs.up_to_date == 'false'
run: npm install
- name: Run migrations
if: steps.check.outputs.up_to_date == 'false' && hashFiles('migrations.json') != ''
run: npx nx migrate --run-migrations
- name: Remove migrations.json
if: steps.check.outputs.up_to_date == 'false'
run: rm -f migrations.json
- name: Generate app token
if: steps.check.outputs.up_to_date == 'false'
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Create pull request
if: steps.check.outputs.up_to_date == 'false'
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.app-token.outputs.token }}
sign-commits: true
branch: build/nx-migrate-${{ steps.check.outputs.latest }}
commit-message: 'build(deps): migrate Nx to ${{ steps.check.outputs.latest }}'
title: 'build(deps): migrate Nx to ${{ steps.check.outputs.latest }}'
body: |
Automated Nx migration from ${{ steps.check.outputs.current }} to ${{ steps.check.outputs.latest }}.
This PR was created by `nx migrate` which also runs any code migrations (codemods) needed for the new version.
Please review the changes and verify that CI passes before merging.