Repository navigation
feat(platform)!: contract references may require the referenced contract's owner relation and config flags #755
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: Book Preview (PR) | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - 'book/**' | |
| - '.github/workflows/book-preview.yml' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: book-preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| preview: | |
| name: Build book preview | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v4 | |
| - name: Install mdBook | |
| run: | | |
| mkdir -p "$HOME/.local/bin" | |
| curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz \ | |
| | tar -xz -C "$HOME/.local/bin" | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| - name: Build book | |
| run: mdbook build book | |
| - name: Upload preview artifact | |
| id: upload | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: book-preview-pr-${{ github.event.pull_request.number }} | |
| path: book/book | |
| retention-days: 30 | |
| - name: Post preview link | |
| # Fork PRs run with a read-only token that cannot post comments | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const runId = context.runId; | |
| const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`; | |
| const artifactUrl = `${repoUrl}/actions/runs/${runId}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const marker = '<!-- book-preview -->'; | |
| const existing = comments.find(c => c.body.includes(marker)); | |
| const body = [ | |
| marker, | |
| `📖 **Book Preview** built successfully.`, | |
| ``, | |
| `Download the preview from the [workflow artifacts](${artifactUrl}).`, | |
| `To view locally: download the artifact, unzip, and open \`index.html\`.`, | |
| ``, | |
| `_Updated at ${new Date().toISOString()}_`, | |
| ].join('\n'); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body, | |
| }); | |
| } |