Skip to content

Publish SDK Reference Docs #1027

Publish SDK Reference Docs

Publish SDK Reference Docs #1027

Workflow file for this run

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."