-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (110 loc) · 4 KB
/
update.yml
File metadata and controls
140 lines (110 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Update NuGet dependencies (daily)
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: update-nuget-deps
cancel-in-progress: true
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Locate solution
id: sln
shell: bash
run: |
set -euo pipefail
SLN="$(ls -1 *.sln 2>/dev/null | head -n 1 || true)"
if [[ -z "${SLN}" ]]; then
SLN="$(find . -maxdepth 5 -name '*.sln' -print | head -n 1 || true)"
fi
if [[ -z "${SLN}" ]]; then
echo "No .sln file found."
exit 1
fi
echo "Found solution: ${SLN}"
echo "sln=${SLN}" >> "$GITHUB_OUTPUT"
- name: Update NuGet packages (per project, only if outdated)
shell: bash
run: |
set -euo pipefail
mapfile -t PROJECTS < <(find . -name '*.csproj' \
-not -path '*/bin/*' \
-not -path '*/obj/*' \
-print | sort)
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
echo "No .csproj files found."
exit 1
fi
echo "Checking ${#PROJECTS[@]} projects:"
printf ' - %s\n' "${PROJECTS[@]}"
any_updates=0
for p in "${PROJECTS[@]}"; do
echo ""
echo "=== Checking outdated: $p ==="
# If dotnet list fails for some reason, fail fast (real problem).
OUTDATED="$(dotnet list "$p" package --outdated)"
echo "$OUTDATED"
# Outdated table rows include '>' marker between requested and latest
if echo "$OUTDATED" | grep -q '>'; then
echo "Outdated packages detected -> updating $p"
dotnet package update --project "$p"
any_updates=1
else
echo "No outdated packages -> skipping update for $p"
fi
done
if [[ $any_updates -eq 0 ]]; then
echo "✅ No package updates were needed."
fi
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Install Playwright CLI
run: dotnet tool install --global Microsoft.Playwright.CLI
- name: Add .NET tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Install Playwright system deps (via CLI)
run: |
playwright install-deps
- name: Install Playwright Browsers
run: playwright install
- name: Test (NUnit)
run: dotnet test Playwright.NUnit.Testing/Playwright.NUnit.Testing.csproj --configuration Release --no-build
- name: Test (TUnit)
run: dotnet run --configuration Release --project Playwright.TUnit.Testing/Playwright.TUnit.Testing.csproj
- name: Commit and push if there are changes
shell: bash
env:
GH_PAT: ${{ secrets.ACTIONS_PUSH_PAT }}
run: |
set -euo pipefail
git config user.name "agray"
git config user.email "agray@users.noreply.github.com"
export GIT_AUTHOR_NAME="agray"
export GIT_AUTHOR_EMAIL="agray@users.noreply.github.com"
export GIT_COMMITTER_NAME="agray"
export GIT_COMMITTER_EMAIL="agray@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "✅ No changes detected."
exit 0
fi
git commit -m "Automated version sync"
git pull --rebase origin main
echo "🔐 Using PAT to push changes..."
git push "https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}" HEAD:main
echo "🚀 Changes committed and pushed to main via PAT."