Skip to content

Commit 7a08b2a

Browse files
committed
add nuget update pipeline
1 parent 8812e1d commit 7a08b2a

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

.github/workflows/update.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Update NuGet dependencies (daily)
2+
3+
on:
4+
schedule:
5+
# Runs daily at 02:00 UTC (adjust as you like)
6+
- cron: "0 2 * * *"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: update-nuget-deps
14+
cancel-in-progress: true
15+
16+
jobs:
17+
update:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
# Needed so we can push back using GITHUB_TOKEN
25+
persist-credentials: true
26+
fetch-depth: 0
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: "10.0.x"
32+
33+
- name: Show .NET info
34+
run: dotnet --info
35+
36+
- name: Locate solution
37+
id: sln
38+
shell: bash
39+
run: |
40+
set -euo pipefail
41+
SLN="$(ls -1 *.sln 2>/dev/null | head -n 1 || true)"
42+
if [[ -z "${SLN}" ]]; then
43+
SLN="$(find . -maxdepth 4 -name '*.sln' -print | head -n 1 || true)"
44+
fi
45+
if [[ -z "${SLN}" ]]; then
46+
echo "No .sln file found."
47+
exit 1
48+
fi
49+
echo "Found solution: ${SLN}"
50+
echo "sln=${SLN}" >> "$GITHUB_OUTPUT"
51+
52+
- name: Restore
53+
run: dotnet restore "${{ steps.sln.outputs.sln }}"
54+
55+
- name: Update NuGet package references
56+
# .NET 10+ command that updates PackageReference versions
57+
# When no package names are provided, it attempts to update all packages in the project/solution.
58+
run: dotnet package update --project "${{ steps.sln.outputs.sln }}"
59+
60+
- name: Build
61+
run: dotnet build "${{ steps.sln.outputs.sln }}" -c Release --no-restore
62+
63+
- name: Test
64+
run: dotnet test "${{ steps.sln.outputs.sln }}" -c Release --no-build
65+
66+
- name: Commit and push if there are changes
67+
shell: bash
68+
env:
69+
GH_PAT: ${{ secrets.ACTIONS_PUSH_PAT }}
70+
run: |
71+
set -euo pipefail
72+
git config user.name "agray"
73+
git config user.email "agray@users.noreply.github.com"
74+
export GIT_AUTHOR_NAME="agray"
75+
export GIT_AUTHOR_EMAIL="agray@users.noreply.github.com"
76+
export GIT_COMMITTER_NAME="agray"
77+
export GIT_COMMITTER_EMAIL="agray@users.noreply.github.com"
78+
79+
git add -A
80+
81+
if git diff --cached --quiet; then
82+
echo "✅ No changes detected after running sync-package-versions.ps1"
83+
exit 0
84+
fi
85+
86+
git commit -m "Automated version sync"
87+
git pull --rebase origin master
88+
89+
echo "🔐 Using PAT to push changes..."
90+
git push "https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}" HEAD:master
91+
92+
echo "🚀 Changes committed and pushed to master via PAT."

PlaywrightTesting.NET.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.1.11304.174 d18.0
4+
VisualStudioVersion = 18.1.11304.174
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Playwright.NUnit.Testing", "Playwright.NUnit.Testing\Playwright.NUnit.Testing.csproj", "{63FFBA8C-2D95-4A54-BB91-8A792920E076}"
77
EndProject
@@ -14,6 +14,7 @@ EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
1515
ProjectSection(SolutionItems) = preProject
1616
.github\workflows\ci.yml = .github\workflows\ci.yml
17+
.github\workflows\update.yml = .github\workflows\update.yml
1718
EndProjectSection
1819
EndProject
1920
Global

0 commit comments

Comments
 (0)