diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3fd3072..35bf2a1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -15,6 +15,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Checkout Examples repo + uses: actions/checkout@v4 + with: + repository: tlaplus/Examples + path: Examples + - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9d2a30..40b45c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [main] +permissions: + contents: read + pull-requests: write + jobs: build: runs-on: ubuntu-latest @@ -13,6 +17,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Checkout Examples repo + uses: actions/checkout@v4 + with: + repository: tlaplus/Examples + path: Examples + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -27,3 +37,41 @@ jobs: - name: Build run: npm run build + + - name: Upload build preview + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: site-preview-pr-${{ github.event.number }} + path: out/ + retention-days: 14 + + - name: Comment on PR with preview link + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const marker = ''; + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const body = `${marker}\nš¦ **Site preview built!** Download the artifact to preview locally:\n\n[**Download preview**](${runUrl}#artifacts)\n\nTo view: unzip, \`cd\` into the folder, then serve with a local HTTP server:\n\`\`\`\nnpx serve .\n# or\npython3 -m http.server\n\`\`\``; + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const existing = comments.find(c => c.body.includes(marker)); + 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: context.issue.number, + body, + }); + } diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 940fe87..c208562 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -21,6 +21,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Checkout Examples repo + uses: actions/checkout@v4 + with: + repository: tlaplus/Examples + path: Examples + - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/.gitignore b/.gitignore index 2543ec0..9e89908 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules/ .next/ out/ +Examples/ *.tsbuildinfo next-env.d.ts diff --git a/public/tlc-worker.html b/public/tlc-worker.html index d928d1f..70097ac 100644 --- a/public/tlc-worker.html +++ b/public/tlc-worker.html @@ -8,6 +8,7 @@