June 28, 2021

Using NuKeeper from GitHub Actions

Automagically keeping your dependencies up-to-date with NuKeeper and GitHub Actions.

Something that is often overlooked in projects is updating the dependencies that a project is using. It's often a boring task, and mostly not prioritized in development processes.

Updating dependencies can be of high value. Obviously bugs can be fixed, security issues can be fixed, new features introduced or even performance improvements can be gained by updating to newer versions of the dependencies you're using.

Automating the tedious task of scanning nuget for all updated packages with NuKeeper

Fortunately there's a tool that makes our lives much easier. According to their own documentation over at https://nukeeper.com:

Nukeeper is a tool to automagically update NuGet packages in all .NET projects.

The idea here is that every once in a while this tool is activated, and it will search your code for all nuget packages you're using. After it's build a distinct overview of all packages and it's versions, it will check the nuget package feeds for updated versions. If it finds updated packages, it will automatically open a Pull Request with the neccessary changes to your project files.

I want this now ❤️

Using GitHub actions we can create an action that does this for us automatically on a schedule we define.

name: NuKeeper Update NuGet Dependencies
on:
schedule:
- cron: 0 11 * * *
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_MULTILEVEL_LOOKUP: false
jobs:
update:
name: Update NuGet Packages
runs-on: ubuntu-latest
steps:
- name: install nukeeper
run: dotnet tool install nukeeper --global
- name: update packages
run: nukeeper repo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY ${{ secrets.NUKEEPER_TOKEN }}

HTH, Svs

© 2020 Stephan van Stekelenburg. All rights reserved.