Update NuGet dependencies (daily) #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Install browser dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libgtk-3-0 \ | |
| libgtk-4-1 \ | |
| libgbm1 \ | |
| libnss3 \ | |
| libasound2t64 \ | |
| libxss1 \ | |
| libxtst6 \ | |
| libx11-xcb1 \ | |
| libxcomposite1 \ | |
| libxdamage1 \ | |
| libxrandr2 \ | |
| libxinerama1 \ | |
| libgl1 \ | |
| libdrm2 \ | |
| libpango-1.0-0 \ | |
| libcairo2 \ | |
| libatspi2.0-0 \ | |
| libcups2 \ | |
| libwoff1 \ | |
| libvpx9 \ | |
| libevent-2.1-7 \ | |
| libopus0 \ | |
| libavif16 \ | |
| libharfbuzz-icu0 \ | |
| libsecret-1-0 \ | |
| libhyphen0 \ | |
| libmanette-0.2-0 \ | |
| libgles2 \ | |
| libx264-164 \ | |
| libgstreamer-plugins-bad1.0-0 \ | |
| libflite1 | |
| - 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 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." |