Skip to content

Commit 334e014

Browse files
new tutorial content automation workflow
1 parent 60b776c commit 334e014

File tree

2 files changed

+99
-26
lines changed

2 files changed

+99
-26
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
# Directory where docs repo is cloned (should match push-docs.sh)
7+
DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"}
8+
9+
# Root of the example apps
10+
EXAMPLES_ROOT="./examples"
11+
12+
# Products to process
13+
PRODUCTS=("passport" "checkout" "orderbook" "contracts")
14+
15+
# Process tutorials for each product
16+
for PRODUCT in "${PRODUCTS[@]}"; do
17+
echo "Processing tutorials for $PRODUCT..."
18+
19+
# Create _tutorials directory in docs repo if it doesn't exist
20+
TUTORIALS_DIR="$DOCS_REPO_DIR/api-docs/sdk-references/$PRODUCT-examples/_tutorials"
21+
mkdir -p "$TUTORIALS_DIR"
22+
23+
# Get all example apps for this product
24+
SAMPLE_APPS=$(ls -d $EXAMPLES_ROOT/$PRODUCT/*/ 2>/dev/null | xargs -n1 basename)
25+
26+
for APP in $SAMPLE_APPS; do
27+
TUTORIAL_FILE="$EXAMPLES_ROOT/$PRODUCT/$APP/tutorial.md"
28+
29+
# Check if tutorial.md exists
30+
if [ -f "$TUTORIAL_FILE" ]; then
31+
echo "Processing tutorial for $APP..."
32+
33+
# Copy the content to a new file named after the app
34+
cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${APP}.md"
35+
echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${APP}.md"
36+
else
37+
echo "No tutorial.md found for $APP, skipping..."
38+
fi
39+
done
40+
41+
# Also copy the generated JSON file
42+
JSON_FILE="$EXAMPLES_ROOT/_parsed/${PRODUCT}-examples.json"
43+
if [ -f "$JSON_FILE" ]; then
44+
# Create directory for JSON file if it doesn't exist
45+
JSON_DIR="$DOCS_REPO_DIR/api-docs/sdk-references/$PRODUCT-examples"
46+
mkdir -p "$JSON_DIR"
47+
48+
# Copy JSON file
49+
cp "$JSON_FILE" "$JSON_DIR/${PRODUCT}-examples.json"
50+
echo "Copied $JSON_FILE to $JSON_DIR/${PRODUCT}-examples.json"
51+
else
52+
echo "Warning: No ${PRODUCT}-examples.json found at $JSON_FILE"
53+
fi
54+
done
55+
56+
echo "Tutorial processing complete."

.github/workflows/publish-docs.yaml

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2525
with:
2626
fetch-depth: 0
27+
# For testing, use the SDK development branch
28+
ref: DVR-330-example-apps-content-autogeneration
2729

2830
- name: Check alpha version
2931
id: alpha_check
@@ -62,14 +64,17 @@ jobs:
6264
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
6365
with:
6466
fetch-depth: 0
67+
# For testing, use the SDK development branch
68+
ref: DVR-330-example-apps-content-autogeneration
6569

6670
- name: Checkout Docs Repo
6771
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
6872
with:
6973
repository: immutable/docs
7074
token: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }}
7175
path: imx-docs
72-
ref: main
76+
# For testing, use the docs development branch
77+
ref: DVR-331-example-app-layout
7378

7479
- name: Setup environment variables
7580
run: |
@@ -104,32 +109,44 @@ jobs:
104109
- name: Update version link
105110
run: ./.github/scripts/update-docs-link.sh
106111

107-
- name: Push SDK Docs to docs
108-
id: docs_push
109-
run: ./.github/scripts/push-docs.sh
112+
- name: Process Example App Tutorials
113+
run: |
114+
# Generate example app JSON files
115+
pnpm parse:examples
116+
117+
# Process tutorials and copy to docs repo
118+
./.github/scripts/process-tutorials.sh
110119
shell: bash
111120

112-
- name: Trigger Netlify Build and Deploy
113-
id: netlify_build
114-
run: curl -X POST -d '{}' ${{ env.NETLIFY_BUILD_HOOK }}
115-
116-
- name: Wait for 10 minutes
117-
# allow Netlify time to build and deploy
118-
run: sleep 600
119-
120-
- name: Check Netlify Site Deployed
121-
id: netlify_deploy
122-
run: ./.github/scripts/check-docs-deployed.sh
121+
- name: Push SDK Docs to docs
122+
id: docs_push
123+
run: |
124+
# Modify push-docs.sh to push to the testing branch
125+
cd "$CLONE_DIR"
126+
git push -u origin DVR-331-example-app-layout
123127
shell: bash
124128

125-
- name: Notify SDK Slack Docs Publish Success
126-
if: ${{ success() && steps.docs_push.conclusion == 'success' && steps.netlify_build.conclusion == 'success' && steps.netlify_deploy.conclusion == 'success' }}
127-
uses: ./.github/actions/notify-slack-publish-status
128-
with:
129-
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.*"
130-
131-
- name: Notify SDK Slack Docs Publish Failure
132-
if: ${{ failure() && steps.docs_version_check.conclusion == 'success' }}
133-
uses: ./.github/actions/notify-slack-publish-status
134-
with:
135-
message: "❌ Failed to publish SDK reference documents. Please check the logs for more details."
129+
# - name: Trigger Netlify Build and Deploy
130+
# id: netlify_build
131+
# run: curl -X POST -d '{}' ${{ env.NETLIFY_BUILD_HOOK }}
132+
133+
# - name: Wait for 10 minutes
134+
# # allow Netlify time to build and deploy
135+
# run: sleep 600
136+
137+
# - name: Check Netlify Site Deployed
138+
# id: netlify_deploy
139+
# run: ./.github/scripts/check-docs-deployed.sh
140+
# shell: bash
141+
142+
# - name: Notify SDK Slack Docs Publish Success
143+
# if: ${{ success() && steps.docs_push.conclusion == 'success' && steps.netlify_build.conclusion == 'success' && steps.netlify_deploy.conclusion == 'success' }}
144+
# uses: ./.github/actions/notify-slack-publish-status
145+
# with:
146+
# 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.*"
147+
148+
# - name: Notify SDK Slack Docs Publish Failure
149+
# if: ${{ failure() && steps.docs_version_check.conclusion == 'success' }}
150+
# uses: ./.github/actions/notify-slack-publish-status
151+
# with:
152+
# message: "❌ Failed to publish SDK reference documents. Please check the logs for more details."

0 commit comments

Comments
 (0)