Skip to content

NuGet Package Update #227

NuGet Package Update

NuGet Package Update #227

Workflow file for this run

name: NuGet Package Update
on:
schedule:
# Runs at 00:00 UTC every day
- cron: '0 0 * * *'
# Allow manual triggering
workflow_dispatch:
env:
DOTNET_VERSION: "9.x.x"
SOLUTION_DIR: "VisualPairCoding"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
update-nuget:
name: Update NuGet Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch all history for all branches and tags
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install NuGet updater
run: dotnet tool install -g dotnet-outdated-tool
- name: Set up Git identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Check for outdated packages
id: check-updates
run: |
cd Source/${{ env.SOLUTION_DIR }}
# Get list of outdated packages
dotnet restore
dotnet list package --outdated --include-transitive --highest-minor | tee outdated.txt
# Check if there are any updates available
if grep -q '> ' outdated.txt; then
echo "updates_available=true" >> $GITHUB_OUTPUT
else
echo "No package updates found."
echo "updates_available=false" >> $GITHUB_OUTPUT
fi
rm outdated.txt
- name: Update packages
if: steps.check-updates.outputs.updates_available == 'true'
run: |
cd Source/${{ env.SOLUTION_DIR }}
# Update all packages to latest version
dotnet outdated -u
# Restore packages after update
dotnet restore
- name: Build and test
if: steps.check-updates.outputs.updates_available == 'true'
run: |
cd Source/${{ env.SOLUTION_DIR }}
dotnet build --configuration Release --no-restore
dotnet test --no-build --verbosity normal --logger "console;verbosity=normal"
- name: Create Pull Request
if: steps.check-updates.outputs.updates_available == 'true'
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: update NuGet packages"
title: "chore: update NuGet packages"
body: |
Automated update of NuGet packages.
This PR was automatically generated by the NuGet package update workflow.
branch: feature/update-nuget-packages
delete-branch: true
draft: false
token: ${{ secrets.GITHUB_TOKEN }}