From 5ad2220be4ce5a0d4e7c7628b45d45110da9ace7 Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 9 Sep 2025 12:20:51 +1000 Subject: [PATCH 1/3] MAINT: use netlify-cli for sending html to netlify --- .github/workflows/ci.yml | 85 +++++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 258e56ee1..90857d219 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,13 @@ jobs: pip install --upgrade "jax[cuda12-local]==0.6.2" pip install numpyro pyro-ppl python scripts/test-jax-install.py + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + - name: Install Netlify CLI + run: npm install -g netlify-cli - name: Check nvidia Drivers shell: bash -l {0} run: nvidia-smi @@ -78,13 +85,73 @@ jobs: with: name: execution-reports path: _build/html/reports - - name: Preview Deploy to Netlify - uses: nwtgck/actions-netlify@v3 + - name: Deploy to Netlify + id: netlify-deploy + run: | + # Deploy to Netlify and capture the deploy URL + DEPLOY_URL=$(netlify deploy \ + --dir=. \ + --site=${{ secrets.NETLIFY_SITE_ID }} \ + --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \ + --json | jq -r '.deploy_url') + + echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_OUTPUT + echo "Preview URL: $DEPLOY_URL" + + - name: Comment PR with preview link + uses: actions/github-script@v7 + with: + script: | + const deployUrl = '${{ steps.netlify-deploy.outputs.DEPLOY_URL }}'; + const comment = `🚀 **Preview deployed!** + + Preview URL: ${deployUrl} + + Built from commit: ${context.sha.substring(0, 7)}`; + + // Check if we already commented on this PR + 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) { + // Update existing comment + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: comment + }); + } else { + // Create new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + } + + - name: Update deployment status + uses: actions/github-script@v7 + if: always() with: - publish-dir: '_build/html/' - production-branch: main - github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Preview Deploy from GitHub Actions" - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + script: | + const deployUrl = '${{ steps.netlify-deploy.outputs.DEPLOY_URL }}'; + const state = '${{ job.status }}' === 'success' ? 'success' : 'failure'; + + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: context.payload.deployment?.id || 0, + state: state, + environment_url: deployUrl, + description: state === 'success' ? 'Preview deployed successfully' : 'Preview deployment failed' + }); From a16c7d556cf9d0eb8a9b75e836bc122a49147a05 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Tue, 9 Sep 2025 12:35:41 +1000 Subject: [PATCH 2/3] Update .github/workflows/ci.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90857d219..c7458f34a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: run: | # Deploy to Netlify and capture the deploy URL DEPLOY_URL=$(netlify deploy \ - --dir=. \ + --dir=_build/html \ --site=${{ secrets.NETLIFY_SITE_ID }} \ --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \ --json | jq -r '.deploy_url') From 06a299326f34579d6869ddb4f71f79cd901bba63 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Tue, 9 Sep 2025 12:35:48 +1000 Subject: [PATCH 3/3] Update .github/workflows/ci.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7458f34a..21eb24060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,11 +147,15 @@ jobs: const deployUrl = '${{ steps.netlify-deploy.outputs.DEPLOY_URL }}'; const state = '${{ job.status }}' === 'success' ? 'success' : 'failure'; - await github.rest.repos.createDeploymentStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - deployment_id: context.payload.deployment?.id || 0, - state: state, - environment_url: deployUrl, - description: state === 'success' ? 'Preview deployed successfully' : 'Preview deployment failed' - }); + if (context.payload.deployment?.id) { + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: context.payload.deployment.id, + state: state, + environment_url: deployUrl, + description: state === 'success' ? 'Preview deployed successfully' : 'Preview deployment failed' + }); + } else { + console.log('No deployment ID found; skipping deployment status update.'); + }