Deploy Docs to GitHub Pages #50
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 Docs to GitHub Pages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Published release tag to deploy, for example v3.0.0' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.release_tag }} | |
| - name: Verify tag, package and npm registry agree | |
| shell: bash | |
| run: | | |
| RELEASE_TAG='${{ inputs.release_tag }}' | |
| if [[ ! "${RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::release_tag must be an exact stable SemVer tag such as v3.0.0" | |
| exit 1 | |
| fi | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| TAG_VERSION=${RELEASE_TAG#v} | |
| REGISTRY_VERSION=$(npm view "monsqlize@${PACKAGE_VERSION}" version --registry=https://registry.npmjs.org/) | |
| if [ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ] || [ "${REGISTRY_VERSION}" != "${PACKAGE_VERSION}" ]; then | |
| echo "::error::tag=${TAG_VERSION}, package=${PACKAGE_VERSION}, registry=${REGISTRY_VERSION} must match" | |
| exit 1 | |
| fi | |
| echo "DOCS_RELEASE_VERSION=${PACKAGE_VERSION}" >> "${GITHUB_ENV}" | |
| echo "DOCS_RELEASE_CHANNEL=stable" >> "${GITHUB_ENV}" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Check docs example matrix | |
| run: node scripts/validation/check-doc-example-matrix.cjs --require-covered | |
| - name: Install website dependencies | |
| working-directory: ./website | |
| run: npm ci | |
| - name: Verify docs site | |
| working-directory: ./website | |
| run: npm run verify | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./website/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Summarize stable docs deployment | |
| shell: bash | |
| run: | | |
| { | |
| echo "## Stable documentation deployed" | |
| echo | |
| echo "Release tag: \`${{ inputs.release_tag }}\`" | |
| echo | |
| echo "Pages URL: ${{ steps.deployment.outputs.page_url }}" | |
| } >> "${GITHUB_STEP_SUMMARY}" |