From 5915f88da71f8c3824e583d203965022666d2f0b Mon Sep 17 00:00:00 2001 From: Marco Spengler Date: Thu, 20 Jun 2024 14:34:13 +0200 Subject: [PATCH] ci: add workflow to automate nx updates (N8N-15) --- .github/workflows/nx-dependency-update.yaml | 68 +++++++++++++++++++++ .gitignore | 1 + 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/nx-dependency-update.yaml diff --git a/.github/workflows/nx-dependency-update.yaml b/.github/workflows/nx-dependency-update.yaml new file mode 100644 index 00000000..d5cb43eb --- /dev/null +++ b/.github/workflows/nx-dependency-update.yaml @@ -0,0 +1,68 @@ +name: nx Dependency Update + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + +permissions: + contents: write + pull-requests: write + +jobs: + update-nx-dependencies: + name: Update nx dependencies and apply migrations + runs-on: ubuntu-latest + # yamllint disable-line rule:line-length + if: github.actor == 'dependabot[bot]' && contains(github.event.pull_request.title, 'bump nx from') + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup git user + uses: fregante/setup-git-user@v2 + + - name: Fetch dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v2 + + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + cache: npm + + - name: Install Dependencies + run: npm ci + + - name: Migrate nx + run: | + npx nx migrate ${{ steps.dependabot-metadata.outputs.new-version }} \ + --from nx@${{ steps.dependabot-metadata.outputs.previous-version }} + + - name: Install updated depenencies + run: npm install + + - name: Commit changes to package(-lock).json + uses: stefanzweifel/git-auto-commit-action@v5 + with: + # yamllint disable-line rule:line-length + commit_message: 'chore: bump nx dependencies to ${{ steps.dependabot-metadata.outputs.new-version }}' + file_pattern: 'package.json package-lock.json' + push_options: --dry-run + skip_fetch: true + skip_checkout: true + + - name: Execute migrations + run: npx nx migrate --run-migrations --if-exists --create-commits + env: + npm_config_legacy_peer_deps: false + + - name: Push changes + run: git push origin HEAD:${{ github.event.pull_request.head.ref }} diff --git a/.gitignore b/.gitignore index e3ba32b2..574cb9a6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.cache /.nx/cache /.nx/workspace-data +/migrations.json # Coverage /coverage