Use Renovate to Automate Node Dependency Version Updates

| 2 min read

This post walks through how to use Renovate to automate keeping your Cypress project Node dependencies up to date by integrating the Renovate bot with your GitHub account.

Renovate will scan GitHub repositories and create a pull request when a dependency is out of date. This post will also create a GitHub workflow to run Cypress tests on the PRs.

Configure GitHub Action Workflow

If you don't already have a GitHub action to run Cypress tests when a pull request is created you can use the example below.

This workflow will install the node dependencies then npm test. If the tests fail screenshots will be published as a job artefact.

Create this file in your project .github/workflows/pullrequest.yml.

name: Cypress Tests

on:
  pull_request:
jobs:
  build:
    name: Cypress tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

      - name: npm install and test
        run: |
          npm install
          npm test

      - name: Upload screenshots
        uses: actions/upload-artifact@v3.1.3
        if: failure()
        with:
          name: cypress-screenshots
          path: cypress/screenshots

You may also want to set a branch protection rule on your main branch that requires this status check to pass before allowing a merge. You can do this in your GitHub project branches settings.

Renovate Config

Renovate works well out of the box but also has a large range of configurations. An example below of renovate.json in my project root assigns the pull requests to my GitHub user handle.

Create this file and add the list of users you need your PRs assigned.

{
    "assignees": ["testingnotebook"]
}

Install Renovate GitHub App

Head to the Renovate app page and click the INSTALL button.

You will need to authorise the Renovate app to have access to your GitHub account. Once you have completed the install head to the configure page and select the repositories you wish for Renovate to scan.

If you now head to your organisation page on developer.mend.io you should see the list of all your selected repositories with their last job run.

Now check your projects for PRs. :)