Record each shell command, and wait on output that arrived after you asked #838
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: Deploy website | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "js/website/**" | |
| - "js/core/**" | |
| - "js/react/**" | |
| - "crates/browser/**" | |
| pull_request: | |
| paths: | |
| - "js/website/**" | |
| - "js/core/**" | |
| - "js/react/**" | |
| - "crates/browser/**" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Deploy to Vercel | |
| id: deploy | |
| run: | | |
| set -o pipefail | |
| args=() | |
| if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| args+=(--prod) | |
| fi | |
| output=$(./bin/deploy-website "${args[@]}" 2>&1 | tee /dev/stderr) || exit $? | |
| url=$(echo "$output" | grep -o 'https://[^ ]*\.vercel\.app' | tail -1) | |
| if [ -z "$url" ]; then | |
| echo "::error::deploy-website succeeded but no Vercel URL was found in its output" >&2 | |
| exit 1 | |
| fi | |
| echo "url=$url" >> "$GITHUB_OUTPUT" | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| - name: Comment preview URL on PR | |
| if: github.event_name == 'pull_request' && steps.deploy.outputs.url | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const body = `🔗 **Preview:** ${{ steps.deploy.outputs.url }}`; | |
| 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.startsWith('🔗 **Preview:**')); | |
| 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, | |
| }); | |
| } |