-
Notifications
You must be signed in to change notification settings - Fork 24
144 lines (121 loc) · 4.76 KB
/
publish-docs.yaml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Publish SDK Reference Docs
on:
workflow_run:
workflows: ["Publish to NPM", "Publish Major Version to NPM"]
types:
- completed
branches:
- main
jobs:
AlphaCheck:
name: Check if SDK version is alpha
runs-on: ubuntu-latest
outputs:
is_alpha: ${{ steps.alpha_check.outputs.is_alpha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check alpha version
id: alpha_check
run: |
VERSION=$(git describe --tags --abbrev=0)
if echo "$VERSION" | grep -q "alpha"; then
echo "Skipping docs generation for alpha version"
echo "is_alpha=true" >> $GITHUB_OUTPUT
exit 0
else
echo "Generating docs for non-alpha version"
echo "is_alpha=false" >> $GITHUB_OUTPUT
fi
shell: bash
PublishDocs:
name: Publish SDK Reference Docs
runs-on: ubuntu-latest
needs: AlphaCheck
if: ${{ needs.AlphaCheck.outputs.is_alpha == 'false' }}
env:
SDK_PUBLISH_SLACK_WEBHOOK: ${{ secrets.SDK_PUBLISH_SLACK_WEBHOOK }}
NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }}
GITHUB_USER: ${{ github.actor }}
IS_ALPHA: ${{ needs.AlphaCheck.outputs.is_alpha }}
steps:
- name: Is Alpha Version
run: |
echo "Is Alpha Version: ${{ env.IS_ALPHA }}"
- name: Check Public Release Branch
if: github.ref != 'refs/heads/main'
run: failure("SDK reference docs should be only published from main branch, current branch ${{ github.ref }}")
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout Docs Repo
uses: actions/checkout@v4
with:
repository: immutable/docs
token: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }}
path: imx-docs
ref: main
- name: Setup environment variables
run: |
echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV
- name: Docs version check
id: docs_version_check
run: ./.github/scripts/check-docs-version.sh
shell: bash
- name: Setup Github
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "yarn"
- name: Restore cached node_modules
id: restore-cache-node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-build-cache-deps-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.restore-cache-node_modules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build
run: export NODE_OPTIONS=--max-old-space-size=6144 && yarn build
- name: Update SDK package.json version
run: |
tmp=$(mktemp)
jq '.version = "${{ env.VERSION }}"' ./sdk/package.json > "$tmp" && mv "$tmp" ./sdk/package.json
shell: bash
- name: Build SDK Docs
run: yarn docs:build
- name: Update version link
run: ./.github/scripts/update-docs-link.sh
- name: Push SDK Docs to docs
id: docs_push
run: ./.github/scripts/push-docs.sh
shell: bash
- name: Trigger Netlify Build and Deploy
id: netlify_build
run: curl -X POST -d '{}' ${{ env.NETLIFY_BUILD_HOOK }}
- name: Wait for 10 minutes
# allow Netlify time to build and deploy
run: sleep 600
- name: Check Netlify Site Deployed
id: netlify_deploy
run: ./.github/scripts/check-docs-deployed.sh
shell: bash
- name: Notify SDK Slack Docs Publish Success
if: ${{ success() && steps.docs_push.conclusion == 'success' && steps.netlify_build.conclusion == 'success' && steps.netlify_deploy.conclusion == 'success' }}
uses: ./.github/actions/notify-slack-publish-status
with:
message: "✅ SDK reference documents published successfully - https://docs.immutable.com/sdk-references/ts-immutable-sdk/${{ env.VERSION }}/\n\n>*`${{ env.GITHUB_USER }}` Please ensure you and the team updated all Sample Code + Guides on the <https://docs.immutable.com|imx-docs site> to reflect the change.*"
- name: Notify SDK Slack Docs Publish Failure
if: ${{ failure() && steps.docs_version_check.conclusion == 'success' }}
uses: ./.github/actions/notify-slack-publish-status
with:
message: "❌ Failed to publish SDK reference documents. Please check the logs for more details."