Publish SDK Reference Docs #1555
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish SDK Reference Docs | |
| on: | |
| workflow_run: | |
| workflows: ["Publish to NPM", "Publish Major Version to NPM"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: public-docs | |
| cancel-in-progress: false | |
| 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@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check alpha version | |
| id: alpha_check | |
| run: | | |
| # Get all tags on current commit | |
| TAGS=$(git tag --points-at HEAD) | |
| echo "Tags on current commit: $TAGS" | |
| # Check if any of them are non-alpha | |
| if echo "$TAGS" | grep -v alpha | grep -q .; then | |
| echo "Found non-alpha tag(s) on current commit" | |
| echo "Generating docs for non-alpha version" | |
| echo "is_alpha=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "No non-alpha tags found on current commit" | |
| echo "Skipping docs generation for alpha version" | |
| echo "is_alpha=true" >> $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@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout Docs Repo | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| 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 | |
| uses: ./.github/actions/setup | |
| - name: Build | |
| run: export NODE_OPTIONS=--max-old-space-size=6144 && pnpm 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: pnpm 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." |