Deploy Documentation #540
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: Deploy Documentation | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v5 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build packages | |
| run: pnpm -r run build | |
| - name: Download UX Studio artifacts | |
| run: | | |
| curl -fsSL https://sfcc-uxstudio.s3.amazonaws.com/uxstudio-4.5.tar.gz -o /tmp/uxstudio-4.5.tar.gz | |
| curl -fsSL https://sfcc-uxstudio.s3.amazonaws.com/uxstudio-4.6.tar.gz -o /tmp/uxstudio-4.6.tar.gz | |
| mkdir -p docs/public/uxstudio | |
| tar -xzf /tmp/uxstudio-4.5.tar.gz -C docs/public/uxstudio | |
| tar -xzf /tmp/uxstudio-4.6.tar.gz -C docs/public/uxstudio | |
| - name: Get latest release tag | |
| id: release | |
| run: | | |
| PKG_TAG=$(git tag --list '@salesforce/*' --sort=-creatordate | head -n1) | |
| DOCS_TAG=$(git tag --list 'docs@*' --sort=-creatordate | head -n1) | |
| LATEST_TAG="" | |
| if [[ -n "$PKG_TAG" && -n "$DOCS_TAG" ]]; then | |
| LATEST_TAG=$(git tag --list '@salesforce/*' --list 'docs@*' --sort=-creatordate | head -n1) | |
| elif [[ -n "$PKG_TAG" ]]; then | |
| LATEST_TAG="$PKG_TAG" | |
| elif [[ -n "$DOCS_TAG" ]]; then | |
| LATEST_TAG="$DOCS_TAG" | |
| fi | |
| echo "Building docs from: ${LATEST_TAG:-<none>}" | |
| echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| - name: Build documentation from release tag | |
| run: | | |
| # Save config and deps from main (has version dropdown and latest dependencies) | |
| cp docs/.vitepress/config.mts /tmp/config.mts | |
| cp docs/package.json /tmp/docs-package.json | |
| cp pnpm-lock.yaml /tmp/pnpm-lock.yaml | |
| # Remove S3-extracted uxstudio files before checkout to avoid conflicts | |
| rm -rf docs/public/uxstudio | |
| # Checkout release tag | |
| git checkout ${{ steps.release.outputs.tag }} | |
| # Restore UX Studio artifacts | |
| rm -rf docs/public/uxstudio | |
| mkdir -p docs/public/uxstudio | |
| tar -xzf /tmp/uxstudio-4.5.tar.gz -C docs/public/uxstudio | |
| tar -xzf /tmp/uxstudio-4.6.tar.gz -C docs/public/uxstudio | |
| # Restore config and deps from main | |
| cp /tmp/config.mts docs/.vitepress/config.mts | |
| cp /tmp/docs-package.json docs/package.json | |
| cp /tmp/pnpm-lock.yaml pnpm-lock.yaml | |
| # Build docs | |
| pnpm install --frozen-lockfile | |
| pnpm -r run build | |
| pnpm run docs:build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: docs/.vitepress/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |