Repository navigation
102 lines (94 loc) · 3.99 KB
/
Copy pathpublish-docs.yml
File metadata and controls
102 lines (94 loc) · 3.99 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
93
94
95
96
97
98
99
100
101
102
name: 📚 Publish docs
# Docs-only commits on main publish on merge. Anything else waits for a
# docs-release-* tag. See .github/scripts/publish-docs.sh.
# docs-live feeds the Mintlify docs until the new docs site replaces them. The docs site is
# published and deployed elsewhere; nothing here deploys it.
on:
push:
branches:
- main
paths:
- "docs/**"
tags:
- "docs-release-*"
workflow_dispatch:
permissions: {}
concurrency:
group: publish-docs
cancel-in-progress: false
jobs:
publish:
runs-on: warp-ubuntu-latest-x64-2x
permissions:
contents: write # pushes docs-live (Mintlify's GitHub app deploys from it) and comments on waiting commits
env:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
steps:
- name: 📥 Checkout main
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
fetch-depth: 0
persist-credentials: false
- name: 📦 Install Mintlify
working-directory: ${{ runner.temp }}
env:
COREPACK_HOME: ${{ runner.temp }}/mintlify-corepack
NPM_CONFIG_CACHE: ${{ runner.temp }}/mintlify-npm-cache
NPM_CONFIG_GLOBALCONFIG: /dev/null
NPM_CONFIG_USERCONFIG: /dev/null
PNPM_HOME: ${{ runner.temp }}/mintlify-pnpm
run: |
mkdir -p "$RUNNER_TEMP/mintlify-tool"
printf '{"private":true}\n' >"$RUNNER_TEMP/mintlify-tool/package.json"
corepack pnpm@10.33.2 --dir "$RUNNER_TEMP/mintlify-tool" add \
--save-exact \
--store-dir "$RUNNER_TEMP/mintlify-pnpm-store" \
--registry=https://registry.npmjs.org/ \
mintlify@4.0.393
- name: 🏗️ Build the docs to publish
id: build
run: |
export LINK_CHECK_CMD="\"$RUNNER_TEMP/mintlify-tool/node_modules/.bin/mintlify\" broken-links"
export RESULT_FILE="$GITHUB_OUTPUT"
export REPORT_FILE="$GITHUB_STEP_SUMMARY"
export NEW_WAITING_FILE="$RUNNER_TEMP/new-waiting"
if [[ "$GITHUB_REF" != refs/tags/* ]]; then
.github/scripts/publish-docs.sh auto
exit 0
fi
.github/scripts/publish-docs.sh check-tag "$GITHUB_SHA"
release=$(.github/scripts/publish-docs.sh release)
.github/scripts/publish-docs.sh build "$release"
- name: 🚀 Push docs-live
if: steps.build.outputs.publish_sha != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_SHA: ${{ steps.build.outputs.publish_sha }}
run: |
auth=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 -w0)
echo "::add-mask::$auth"
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $auth" \
push origin "$PUBLISH_SHA:refs/heads/docs-live"
# Comments are a courtesy: a failed one must not fail the run after docs-live moved.
- name: 💬 Comment on docs-only commits that are waiting
if: steps.build.outputs.publish_sha != ''
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
[[ -s "$RUNNER_TEMP/new-waiting" ]] || exit 0
while IFS=$'\t' read -r sha reason; do
[[ -n "$sha" ]] || continue
if [[ "$reason" == conflict:* ]]; then
why="it conflicts with unpublished changes to ${reason#conflict: }"
else
why="it would leave a broken link until other unpublished docs go live"
fi
gh api "repos/$GITHUB_REPOSITORY/commits/$sha/comments" \
-f body="This docs-only change is waiting for the next docs release: $why. It will go live with the next \`docs-release-*\` tag that includes it." \
>/dev/null
done <"$RUNNER_TEMP/new-waiting"