N8N-15 Add workflow to automate nx updates #1
Workflow file for this run
This file contains 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
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 | |
if: 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 | |
# Ignore nx migrations.json, otherwise it would be committed with the first executed migration | |
- name: Ignore nx migrations.json | |
run: echo "migrations.json" >> .git/info/exclude | |
- name: Extract source nx version | |
id: source-nx-version | |
# yamllint disable-line rule:line-length | |
run: echo "version=$(echo "${{ github.event.pull_request.title }}" | sed -n 's/.*from \([^ ]*\).*/\1/p')" >> "$GITHUB_OUTPUT" | |
- name: Extract target nx version | |
id: target-nx-version | |
# yamllint disable-line rule:line-length | |
run: echo "version=$(echo "${{ github.event.pull_request.title }}" | sed -n 's/.*to \([^ ]*\).*/\1/p')" >> "$GITHUB_OUTPUT" | |
- 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.target-nx-version.outputs.version }} \ | |
--from nx@${{ steps.source-nx-version.outputs.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.target-nx-version.outputs.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 }} |