|
| 1 | +name: Deploy Trace Viewer Demo |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: pages-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + deploy: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: dtolnay/rust-toolchain@stable |
| 23 | + |
| 24 | + - uses: Swatinem/rust-cache@v2 |
| 25 | + |
| 26 | + - name: Build demo trace |
| 27 | + run: cargo run --example realistic_workload |
| 28 | + timeout-minutes: 5 |
| 29 | + |
| 30 | + - name: Assemble site |
| 31 | + run: | |
| 32 | + mkdir -p _site |
| 33 | + cp dial9-tokio-telemetry/trace_viewer.html _site/trace_viewer.html |
| 34 | + cp realistic_trace.bin _site/demo.bin |
| 35 | + cp demo/index.html _site/index.html |
| 36 | +
|
| 37 | + - name: Deploy (main) |
| 38 | + if: github.ref == 'refs/heads/main' |
| 39 | + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 |
| 40 | + with: |
| 41 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + publish_dir: ./_site |
| 43 | + |
| 44 | + - name: Deploy (PR preview) |
| 45 | + if: github.event_name == 'pull_request' |
| 46 | + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 |
| 47 | + with: |
| 48 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + publish_dir: ./_site |
| 50 | + destination_dir: pr/${{ github.event.number }} |
| 51 | + |
| 52 | + - name: Comment PR with preview link |
| 53 | + if: github.event_name == 'pull_request' |
| 54 | + uses: actions/github-script@v7 |
| 55 | + with: |
| 56 | + script: | |
| 57 | + const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr/${context.issue.number}/`; |
| 58 | + const body = `🔍 **Trace Viewer Preview:** ${url}`; |
| 59 | + const { data: comments } = await github.rest.issues.listComments({ |
| 60 | + ...context.repo, issue_number: context.issue.number |
| 61 | + }); |
| 62 | + const existing = comments.find(c => c.body.includes('Trace Viewer Preview')); |
| 63 | + if (existing) { |
| 64 | + await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body }); |
| 65 | + } else { |
| 66 | + await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body }); |
| 67 | + } |
0 commit comments