Skip to content

Commit b2eacd5

Browse files
adrianhallahall
andauthored
ci: validate docs on PR and only deploy Pages on release (#570)
* ci: validate docs on PR and only deploy Pages on release - build-docs.yml: add a pull_request trigger (and keep push to main, for parity) that runs a new 'validate' job — a strict mkdocs build to catch broken internal links/anchors/nav entries, plus lychee to catch dead external links. Never deploys. - Gate the 'deploy' job to release: published (or a manual dispatch against a release tag), matching the build-library.yml/build-template.yml convention, instead of deploying on every push to main. - Move the Pages-specific permissions/concurrency group and the configure-pages step to the 'deploy' job only, so PR/push validation runs are unaffected and don't need pages:write. - Fix the broken links/anchors surfaced by the new checks: a stale self-referential anchor link, two dead GitHub file/profile links, a removed test-only MySQL doc link, a moved Azure Cosmos DB for MongoDB doc URL, an old Auth0 quickstart URL, and a URL missing a '/'. Closes #562 * ci: exclude dotnet.microsoft.com from link check (bot-blocked from CI IPs) The live pull_request run on PR #570 showed dotnet.microsoft.com returning 403 to the GitHub-hosted runner (same class of CDN/WAF bot-blocking as the already-excluded dev.mysql.com and developers.facebook.com); the link is live (302) from a normal client. --------- Co-authored-by: ahall <ahall@cloudflare.com>
1 parent 98ee3ea commit b2eacd5

9 files changed

Lines changed: 71 additions & 24 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
name: Deploy documentation site to GitHub Pages
1+
name: Build and Deploy Documentation Site
22

33
on:
44
push:
55
branches: [ main ]
6-
paths: [ 'docs/**', 'mkdocs.yml', 'mkdocs.shared.yml', 'mkdocs.production.yml' ]
6+
paths: [ 'docs/**', 'mkdocs.yml', 'mkdocs.shared.yml', 'mkdocs.production.yml', '.github/workflows/build-docs.yml' ]
7+
pull_request:
8+
branches: [ main ]
9+
paths: [ 'docs/**', 'mkdocs.yml', 'mkdocs.shared.yml', 'mkdocs.production.yml', '.github/workflows/build-docs.yml' ]
10+
release:
11+
types: [ published ]
712
workflow_dispatch:
813

914
permissions:
1015
contents: read
11-
pages: write
12-
id-token: write
13-
14-
concurrency:
15-
group: "pages"
16-
cancel-in-progress: false
1716

1817
defaults:
1918
run:
2019
shell: bash
2120

2221
jobs:
22+
# Builds the production site and uploads it as a Pages artifact. Only needs to run when the
23+
# artifact might actually be deployed (see the 'deploy' job below).
2324
build:
25+
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
2426
runs-on: ubuntu-latest
2527
steps:
2628
- name: Checkout Repository
@@ -36,26 +38,72 @@ jobs:
3638
- name: Install mkdocs
3739
run: pip install mkdocs mkdocs-mermaid2-plugin
3840

39-
- name: Setup Pages
40-
id: pages
41-
uses: actions/configure-pages@v6
42-
4341
- name: Generate site
44-
run : mkdocs build -f ./mkdocs.production.yml
42+
run: mkdocs build -f ./mkdocs.production.yml
4543

4644
- name: Upload artifact
4745
uses: actions/upload-pages-artifact@v5
4846
with:
4947
path: ./site
5048

51-
# Deployment job
49+
# Validates the docs site without ever deploying it: a strict mkdocs build catches broken
50+
# internal links/anchors/nav entries, and lychee catches dead external links. Runs on every PR
51+
# (and push to main, for parity) so problems are caught before they reach a release. --strict is
52+
# deliberately only used here (not baked into mkdocs.production.yml or used by the 'build' job
53+
# above) so that a stray warning can never block the artifact that 'deploy' publishes.
54+
validate:
55+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout Repository
59+
uses: actions/checkout@v7
60+
61+
- name: Install Python
62+
uses: actions/setup-python@v6
63+
with:
64+
python-version: 3.x
65+
66+
- name: Install mkdocs
67+
run: pip install mkdocs mkdocs-mermaid2-plugin
68+
69+
- name: Validate site (strict build)
70+
run: mkdocs build --strict -f ./mkdocs.production.yml
71+
72+
- name: Check for broken links
73+
uses: lycheeverse/lychee-action@v2
74+
with:
75+
args: >-
76+
--no-progress
77+
--scheme https --scheme http
78+
--user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
79+
--exclude "^https://dev\.mysql\.com/"
80+
--exclude "^https://developers\.facebook\.com/"
81+
--exclude "^https://dotnet\.microsoft\.com/"
82+
'docs/**/*.md'
83+
token: ${{ secrets.GITHUB_TOKEN }}
84+
fail: true
85+
86+
# Only deploys to GitHub Pages on a published release (or a manual dispatch against a release
87+
# tag), never on every push to main and never on a plain feature-branch dispatch.
5288
deploy:
89+
if: >-
90+
${{ github.event_name == 'release' ||
91+
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')) }}
92+
needs: build
93+
permissions:
94+
pages: write
95+
id-token: write
96+
concurrency:
97+
group: "pages"
98+
cancel-in-progress: false
5399
environment:
54100
name: github-pages
55101
url: ${{ steps.deployment.outputs.page_url }}
56102
runs-on: ubuntu-latest
57-
needs: build
58103
steps:
104+
- name: Setup Pages
105+
uses: actions/configure-pages@v6
106+
59107
- name: Deploy to GitHub Pages
60108
id: deployment
61109
uses: actions/deploy-pages@v5

docs/in-depth/client/advanced/maui-aot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ When using [Native AOT with .NET MAUI](https://learn.microsoft.com/dotnet/maui/d
99
The following are basic instructions on how to fulfill these requirements. However, you should consult the official documentation (linked above) for each requirement.
1010

1111
!!! info
12-
Thanks to [Richard Perry](https://github.com/richard-einfinity) for providing the detailed instructions for enabling Native AOT support.
12+
Thanks to Richard Perry for providing the detailed instructions for enabling Native AOT support.
1313

1414
## Compiled models
1515

docs/in-depth/server/db/cosmos-sdk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Use the [CommunityToolkit.Datasync.Server.CosmosDb](https://www.nuget.org/packag
1212
Azure Cosmos DB is a fully managed NoSQL database for high-performance applications of any size or scale. See [Azure Cosmos DB for NoSQL .NET SDK](https://learn.microsoft.com/azure/cosmos-db/nosql/quickstart-dotnet) for information on using Azure Cosmos DB via the SDK.
1313

1414
!!! info
15-
The Cosmos DB library and sample has been kindly contributed to the community by [@richard-einfinity](https://github.com/richard-einfinity).
15+
The Cosmos DB library and sample has been kindly contributed to the community by @richard-einfinity.
1616

1717
## Set up
1818

docs/in-depth/server/db/cosmos.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Azure Cosmos DB is a fully managed NoSQL database for high-performance applicati
4343

4444
You must include a composite index for each combination of filters that you require. A "client-side evaluation" exception will be generated (which is turned into a `400 Bad Request` by the server) if you do not have the appropriate composite indices for the request.
4545

46-
You can also review our [bicep module](https://github.com/CommunityToolkit/Datasync/blob/main/tests/infra/databases/cosmos.bicep) that we use for testing.
46+
You can also review the [bicep module](https://github.com/CommunityToolkit/Datasync/blob/main/samples/datasync-server-cosmosdb-singlecontainer/infra/resources.bicep) used by our Cosmos DB sample.
4747

4848
If you pull a subset of items in the table, ensure you specify all properties involved in the query.
4949

docs/in-depth/server/db/mongodb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ In your table controller:
3232

3333
## Known issues
3434

35-
The MongoDB implementation within Cosmos is split into vCore and RU format (also known as dedicated and serverless SKUs). Do not use the "serverless" or RU SKU. Ensure you are using Azure Cosmos DB for MongoDB (vCore). For more information, see [the Azure documentation](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/).
35+
The MongoDB implementation within Cosmos is split into vCore and RU format (also known as dedicated and serverless SKUs). Do not use the "serverless" or RU SKU. Ensure you are using Azure Cosmos DB for MongoDB (vCore). For more information, see [the Azure documentation](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/overview).
3636

3737
## Support and further information
3838

3939
* [MongoDb C# Driver (v3.1)](https://www.mongodb.com/docs/drivers/csharp/current/?msockid=3814d66fce6360e01644c3edcf2061bc)
40-
* [Azure Cosmos DB for MongoDB (vCore)](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/)
40+
* [Azure Cosmos DB for MongoDB (vCore)](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/overview)

docs/in-depth/server/db/mysql.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ In the `OnModelCreating()` method of your context, add the following for each en
2525

2626
* [Official docs: MySql and Entity Framework Core](https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html)
2727
* [Pomelo docs: MySql](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql)
28-
* [Test MySQL Context](https://github.com/CommunityToolkit/Datasync/blob/main/tests/CommunityToolkit.Datasync.TestCommon/Databases/MySQL/MysqlDbContext.cs)

docs/tutorial/client/part-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Each operation can take a `DatasyncServiceOptions` object with the following pro
174174

175175
## Querying for data
176176

177-
The final method in our sample implementation is the query interface. The `DatasyncServiceClient<TEntity>` class implements `TableQuery` - a subset of LINQ that is supported by our implementation of OData. When the query is transmitted to the remote service, it is turned into an OData query string. Full details are provided in the [in-depth documentation](https://communitytoolkit.github.io/Datasync/in-depth/client/online-operations/index.html#querying-for-data). To query for all data:
177+
The final method in our sample implementation is the query interface. The `DatasyncServiceClient<TEntity>` class implements `TableQuery` - a subset of LINQ that is supported by our implementation of OData. When the query is transmitted to the remote service, it is turned into an OData query string. Full details are provided in the [in-depth documentation](../../in-depth/client/online.md#querying-for-data). To query for all data:
178178

179179
public async Task<List<TodoItem>> GetAllTodoItemsAsync(CancellationToken cancellationToken = default)
180180
=> await client.ToListAsync(cancellationToken);

docs/tutorial/client/part-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ In the [next tutorial](./part-3.md), we'll take a final look at the online clien
285285
[OIDC]: https://www.microsoft.com/security/business/security-101/what-is-openid-connect-oidc?msockid=3814d66fce6360e01644c3edcf2061bc
286286
[Google]: https://developers.google.com/identity/openid-connect/openid-connect
287287
[Facebook]: https://developers.facebook.com/docs/facebook-login
288-
[Auth0]: https://auth0.com/docs/quickstart/backend/aspnet-core-webapi/01-authorization
288+
[Auth0]: https://auth0.com/docs/quickstart/backend/aspnet-core-webapi
289289
[OpenID Dict]: https://openiddict.com/
290290
[Duende Identity Server]: https://duendesoftware.com/products/identityserver
291291
[Microsoft Entra ID]: https://learn.microsoft.com/en-us/entra/fundamentals/whatis

docs/tutorial/server/part-4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Now, I want to implement some business rules:
5353
This will demonstrate the first two methods that are needed for an access control provider.
5454

5555
!!! tip Using the IHttpContextAccessor
56-
Most access control providers need asynchronous access to the `HttpContext` of a request. This is handled using the `IHttpContextAccessor`. For details, see [the documentation](https://learn.microsoft.comaspnet/core/fundamentals/http-context). The documentation will tell you to add the following to your application services.
56+
Most access control providers need asynchronous access to the `HttpContext` of a request. This is handled using the `IHttpContextAccessor`. For details, see [the documentation](https://learn.microsoft.com/aspnet/core/fundamentals/http-context). The documentation will tell you to add the following to your application services.
5757

5858
```csharp
5959
builder.Services.AddHttpContextAccessor();

0 commit comments

Comments
 (0)