Skip to content

Commit ffbad63

Browse files
committed
fix: check links on preview
1 parent 1e7a7bb commit ffbad63

File tree

4 files changed

+155
-61
lines changed

4 files changed

+155
-61
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Generate Fern Docs Preview'
2+
description: 'Generates a Fern documentation preview and comments the URL in a PR'
3+
4+
inputs:
5+
github-token:
6+
description: 'GitHub token for creating deployments and comments'
7+
required: true
8+
fern-token:
9+
description: 'Fern API token for publishing docs'
10+
required: true
11+
ref:
12+
description: 'Git ref to create deployment for (usually github.head_ref for PRs)'
13+
required: true
14+
environment:
15+
description: 'Deployment environment name'
16+
required: false
17+
default: 'docs-preview'
18+
19+
outputs:
20+
preview-url:
21+
description: 'The URL where the preview documentation was published'
22+
value: ${{ steps.generate-preview.outputs.url }}
23+
status:
24+
description: 'The outcome of the preview generation (success, failure, etc.)'
25+
value: ${{ steps.generate-preview.outcome }}
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- name: Setup Docs
31+
uses: ./.github/actions/setup-docs
32+
with:
33+
docs-github-token: ${{ inputs.github-token }}
34+
35+
- name: Set Build Comment to In Progress
36+
uses: actions/github-script@v7
37+
with:
38+
github-token: ${{ inputs.github-token }}
39+
script: |
40+
const workspace = process.env.GITHUB_WORKSPACE;
41+
const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
42+
43+
await updatePreviewComment({
44+
github,
45+
context,
46+
status: 'building',
47+
});
48+
49+
- name: Generate Fern Docs Preview
50+
id: generate-preview
51+
uses: ./.github/actions/publish-fern
52+
with:
53+
github-token: ${{ inputs.github-token }}
54+
fern-token: ${{ inputs.fern-token }}
55+
environment: ${{ inputs.environment }}
56+
ref: ${{ inputs.ref }}
57+
preview: "true"
58+
59+
- name: Comment Preview URL in PR
60+
uses: actions/github-script@v7
61+
if: always()
62+
with:
63+
github-token: ${{ inputs.github-token }}
64+
script: |
65+
const workspace = process.env.GITHUB_WORKSPACE;
66+
const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
67+
68+
await updatePreviewComment({
69+
github,
70+
context,
71+
previewUrl: '${{ steps.generate-preview.outputs.url }}',
72+
status: '${{ steps.generate-preview.outcome }}',
73+
});

.github/workflows/on-pull-request.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,31 @@ jobs:
3636
env:
3737
TITLE: ${{ github.event.pull_request.title }}
3838
run: echo "$TITLE" | yarn commitlint
39+
40+
preview:
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
deployments: write
45+
pull-requests: write
46+
47+
steps:
48+
- name: Checkout aa-sdk
49+
uses: actions/checkout@v4
50+
51+
- name: Generate Documentation Preview
52+
id: preview
53+
uses: ./.github/actions/preview-fern-docs
54+
with:
55+
github-token: ${{ github.token }}
56+
fern-token: ${{ secrets.FERN_TOKEN }}
57+
ref: ${{ github.head_ref }}
3958

4059
lint_docs:
4160
name: Lint Documentation
4261
runs-on: ubuntu-latest
43-
needs: changes
44-
if: ${{ needs.changes.outputs.docs == 'true' }}
62+
needs: [changes, preview]
63+
if: ${{ needs.changes.outputs.docs == 'true' && needs.preview.outputs.preview-url != '' }}
4564
steps:
4665
- name: "Checkout files"
4766
uses: actions/checkout@v3
@@ -67,7 +86,9 @@ jobs:
6786
vale --version
6887
6988
- name: Run documentation linting
70-
run: yarn lint:docs
89+
run: |
90+
echo "Preview URL: ${{ needs.preview.outputs.preview-url }}"
91+
yarn lint:docs --base-url "${{ needs.preview.outputs.preview-url }}"
7192
7293
check_broken_links:
7394
name: Check Broken Links
Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
name: Generate Fern Docs Preview
2-
3-
on:
4-
pull_request:
5-
6-
jobs:
7-
preview:
8-
runs-on: ubuntu-latest
9-
permissions:
10-
contents: read
11-
deployments: write
12-
pull-requests: write
13-
14-
steps:
15-
- name: Checkout aa-sdk
16-
uses: actions/checkout@v4
17-
18-
- name: Setup Docs
19-
uses: ./.github/actions/setup-docs
20-
21-
- name: Set Build Comment to In Progress
22-
uses: actions/github-script@v7
23-
with:
24-
script: |
25-
const workspace = process.env.GITHUB_WORKSPACE;
26-
const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
27-
28-
await updatePreviewComment({
29-
github,
30-
context,
31-
status: 'building',
32-
});
33-
34-
- name: Generate Fern Docs Preview
35-
id: preview
36-
uses: ./.github/actions/publish-fern
37-
with:
38-
github-token: ${{ github.token }}
39-
fern-token: ${{ secrets.FERN_TOKEN }}
40-
environment: docs-preview
41-
ref: ${{ github.head_ref }}
42-
preview: "true"
43-
44-
- name: Comment Preview URL in PR
45-
uses: actions/github-script@v7
46-
if: always()
47-
with:
48-
script: |
49-
const workspace = process.env.GITHUB_WORKSPACE;
50-
const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
51-
52-
await updatePreviewComment({
53-
github,
54-
context,
55-
previewUrl: '${{ steps.preview.outputs.url }}',
56-
status: '${{ steps.preview.outcome }}',
57-
});
1+
# name: Generate Fern Docs Preview
2+
3+
# on:
4+
# pull_request:
5+
6+
# jobs:
7+
# preview:
8+
# runs-on: ubuntu-latest
9+
# permissions:
10+
# contents: read
11+
# deployments: write
12+
# pull-requests: write
13+
14+
# steps:
15+
# - name: Checkout aa-sdk
16+
# uses: actions/checkout@v4
17+
18+
# - name: Setup Docs
19+
# uses: ./.github/actions/setup-docs
20+
21+
# - name: Set Build Comment to In Progress
22+
# uses: actions/github-script@v7
23+
# with:
24+
# script: |
25+
# const workspace = process.env.GITHUB_WORKSPACE;
26+
# const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
27+
28+
# await updatePreviewComment({
29+
# github,
30+
# context,
31+
# status: 'building',
32+
# });
33+
34+
# - name: Generate Fern Docs Preview
35+
# id: preview
36+
# uses: ./.github/actions/publish-fern
37+
# with:
38+
# github-token: ${{ github.token }}
39+
# fern-token: ${{ secrets.FERN_TOKEN }}
40+
# environment: docs-preview
41+
# ref: ${{ github.head_ref }}
42+
# preview: "true"
43+
44+
# - name: Comment Preview URL in PR
45+
# uses: actions/github-script@v7
46+
# if: always()
47+
# with:
48+
# script: |
49+
# const workspace = process.env.GITHUB_WORKSPACE;
50+
# const { updatePreviewComment } = await import(`${workspace}/docs-site/scripts/preview-comment.js`);
51+
52+
# await updatePreviewComment({
53+
# github,
54+
# context,
55+
# previewUrl: '${{ steps.preview.outputs.url }}',
56+
# status: '${{ steps.preview.outcome }}',
57+
# });

0 commit comments

Comments
 (0)