Skip to content

timonmasberg/nx-migration-gh-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

NX Migration Action

This Action checks for new versions of NX based on your version of nxfound in the package.json. If a new version exists, it automatically runs nx migrate latest, installs all dependencies, applies all migrations and finally opens a pull request.

Usage

The easiest way is to check for new versions with a scheduled workflow. Make sure to checkout the branch you want apply the migrations in case there is a new version of NX. The Action will create commits for the applied migrations.

For a detailed description of all parameters check the action.yml.

name: Check for new NX version

on:
  schedule:
    - cron: "0 0 * * *" # every day at midnight

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
    - run: npm ci
    - uses: timonmasberg/nx-migration-gh-action@v1.0.0
      with:
        repoToken: ${{ secrets.GITHUB_TOKEN }}
        # Optional:
        prTitle: 'Migrates NX to $VERSION'
        includeMigrationsFile: false # `migrations.json` will not be included in this PR.
        base: 'dev'

You can also use this action in other workflow events.

Make sure you have set the necessary workflow permissions:

  • Read and write permissions
  • Allow GitHub Actions to create and approve Pull Requests

Contribute

As I have done this mostly just to fit our needs over at Kordis and Cartesius.io, this might lack some features or does not cover some edge cases. Also tests are currently rare ;)
I highly appreciate any contribution.

Make sure to run npm run all before pushing and to check-in the dist folder if you make changes in src.