Remove Markdoc and migrate to MDX #1478
Workflow file for this run
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: Build & Deploy | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # needed for committing changes | |
| pages: write | |
| id-token: write | |
| pull-requests: write # needed for commenting on PRs | |
| concurrency: | |
| group: "pages-${{ github.ref }}" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # needed for checking changes and pushing | |
| submodules: recursive | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Setup Node.js and pnpm | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --prod | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Sync external content | |
| run: | | |
| pnpm sync:changelog | |
| - name: Setup GitHub Pages | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| - name: Build with Astro | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| pnpm astro build \ | |
| --site "https://tenzir-docs-preview-${{ github.event.pull_request.number }}.surge.sh" | |
| else | |
| CI_BUILD=true pnpm astro build \ | |
| --site "${{ steps.pages.outputs.origin }}" \ | |
| --base "${{ steps.pages.outputs.base_path }}" | |
| fi | |
| - name: Upload artifact | |
| if: github.event_name != 'pull_request' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| - name: Deploy PR Preview | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| # To create a surge.sh token, run `npx durge login` and `npx surge token`. | |
| npm install -g surge | |
| surge ./dist https://tenzir-docs-preview-${{ github.event.pull_request.number }}.surge.sh --token ${{ secrets.SURGE_TOKEN }} | |
| - name: Comment PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const comment = `🚀 **Preview deployed!** | |
| Visit the preview at: https://tenzir-docs-preview-${{ github.event.pull_request.number }}.surge.sh | |
| This preview will be updated automatically on new commits.`; | |
| // Find existing comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('Preview deployed!') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: comment | |
| }); | |
| } | |
| deploy: | |
| name: Deploy | |
| if: github.ref == 'refs/heads/main' | |
| needs: build | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |