|
| 1 | +name: Update API Docs |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + skiasharp-branch: |
| 7 | + description: 'SkiaSharp branch to generate docs from' |
| 8 | + type: string |
| 9 | + default: 'main' |
| 10 | + schedule: |
| 11 | + - cron: '0 6 * * *' # daily at 6 AM UTC |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + update-docs: |
| 19 | + runs-on: windows-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout SkiaSharp |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + repository: mono/SkiaSharp |
| 26 | + ref: ${{ inputs.skiasharp-branch || 'main' }} |
| 27 | + fetch-depth: 1 |
| 28 | + |
| 29 | + - name: Checkout docs |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + path: docs |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Setup .NET |
| 36 | + uses: actions/setup-dotnet@v4 |
| 37 | + with: |
| 38 | + dotnet-version: '8.0.x' |
| 39 | + |
| 40 | + - name: Install GTK# 2 |
| 41 | + shell: pwsh |
| 42 | + run: | |
| 43 | + $msiUrl = "https://github.com/mono/gtk-sharp/releases/download/2.12.45/gtk-sharp-2.12.45.msi" |
| 44 | + $msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi" |
| 45 | + Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath |
| 46 | + Start-Process msiexec.exe -ArgumentList "/i", $msiPath, "/quiet", "/norestart" -Wait -NoNewWindow |
| 47 | +
|
| 48 | + - name: Restore tools |
| 49 | + run: dotnet tool restore |
| 50 | + |
| 51 | + - name: Download latest NuGet packages |
| 52 | + run: dotnet cake --target=docs-download-output |
| 53 | + |
| 54 | + - name: Regenerate API docs |
| 55 | + run: dotnet cake --target=update-docs |
| 56 | + |
| 57 | + - name: Create pull request |
| 58 | + shell: pwsh |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ github.token }} |
| 61 | + run: | |
| 62 | + cd docs |
| 63 | + git add -A |
| 64 | + git diff --cached --quiet |
| 65 | + if ($LASTEXITCODE -eq 0) { |
| 66 | + Write-Host "No documentation changes detected" |
| 67 | + exit 0 |
| 68 | + } |
| 69 | + git config user.name "github-actions[bot]" |
| 70 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 71 | + git checkout -B automation/update-api-docs |
| 72 | + git commit -m "Update API docs from latest CI build" |
| 73 | + git push origin automation/update-api-docs --force |
| 74 | + # Create PR if one doesn't already exist |
| 75 | + $existing = gh pr list --head automation/update-api-docs --state open --json number --jq '.[0].number' |
| 76 | + if ($existing) { |
| 77 | + Write-Host "PR #$existing already exists, force-pushed updates" |
| 78 | + } else { |
| 79 | + gh pr create --base main --head automation/update-api-docs ` |
| 80 | + --title "Update API docs from latest CI build" ` |
| 81 | + --body "Automated update of XML API documentation generated from the latest CI NuGet packages.`n`nThis PR was created by the [Update API Docs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow." |
| 82 | + } |
0 commit comments