Repository navigation
92 lines (81 loc) · 3.13 KB
/
Copy pathdocs.reusable.yaml
File metadata and controls
92 lines (81 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Docs Publishing (Reusable)
on:
workflow_call:
inputs:
docs_changed:
required: true
type: string
is_canary:
required: true
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-docs
cancel-in-progress: true
jobs:
publish-docs:
name: "publish docs"
runs-on: blacksmith-4vcpu-ubuntu-2404
if: ${{ inputs.docs_changed == 'true' || inputs.is_canary }}
permissions: write-all
environment:
name: ${{ inputs.is_canary && 'boundary-tools-prod' || 'boundary-tools-dev' }}
steps:
- name: Checkout repository
uses: useblacksmith/checkout@v1
with:
persist-credentials: false
- name: Start deployment
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: docs-${{ inputs.is_canary && 'prod' || 'dev' }}
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '20'
- name: Install Fern
run: npm install -g fern-api@4.57.0
- name: Check documentation
run: fern check --strict-broken-links
- name: Generate preview URL
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/canary" ]; then
OUTPUT=$(fern generate --docs 2>&1) || true
else
OUTPUT=$(fern generate --docs --preview 2>&1) || true
fi
echo "$OUTPUT"
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
echo "🌿 Preview your docs: $URL" | tee preview_url.txt
- name: Comment URL in PR
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: marocchino/sticky-pull-request-comment@v3.0.5
with:
header: docs-preview
path: preview_url.txt
- name: Extract docs URL
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
id: docs_url
run: |
if [ -f preview_url.txt ]; then
URL=$(cat preview_url.txt | grep -oP '🌿 Preview your docs: \K.*' || echo "")
echo "url=$URL" >> $GITHUB_OUTPUT
else
echo "url=" >> $GITHUB_OUTPUT
fi
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.docs_url.outputs.url }}