Update NuGet dependencies (daily) #4
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: Restore | |
| # run: dotnet restore "${{ steps.sln.outputs.sln }}" | |
| - name: Update NuGet packages (per project) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # Find csproj files (exclude obj/bin to avoid weirdness) | |
| 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 "Updating ${#PROJECTS[@]} projects:" | |
| printf ' - %s\n' "${PROJECTS[@]}" | |
| # Update each project individually (workaround for solution-level unsupported update) | |
| for p in "${PROJECTS[@]}"; do | |
| echo "" | |
| echo "=== Updating: $p ===" | |
| dotnet package update --project "$p" | |
| done | |
| - 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 after running sync-package-versions.ps1" | |
| 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." |