Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ jobs:
name: Web Build
runs-on: ubuntu-latest
needs: [web-init, web-lint, web-typecheck]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -361,6 +360,90 @@ jobs:
packages/web/build-production
packages/web/build-ssr-production

web-deploy-preview:
name: Web Deploy Preview
runs-on: ubuntu-latest
needs: web-build
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download builds
uses: actions/download-artifact@v4
with:
name: builds
path: packages/web

- name: Move build
run: |
cd packages/web
mv build-production build
mv build-ssr-production build-ssr

- name: Copy robots.txt
run: |
cd packages/web
cp ./robots.txt build
cp ./robots.txt build-ssr/client

- name: Copy .well-known files
run: |
cd packages/web
cp -r ./public/.well-known build 2>/dev/null || true

- name: Deploy to Cloudflare (Preview)
id: deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
cd packages/web
npm_config_yes=true npx wrangler@4.54.0 deploy --config ./src/ssr/wrangler.toml --env preview
npm_config_yes=true npx wrangler@4.54.0 deploy --config ./wrangler.toml --env preview 2>&1 | tee deploy.log
PREVIEW_URL=$(grep -oE 'https://[^[:space:]]+\.workers\.dev' deploy.log | tail -1) || echo "https://audius-web-preview.workers.dev"
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT

- name: Comment on PR with preview URL
uses: actions/github-script@v7
if: steps.deploy.outcome == 'success' && github.event_name == 'pull_request'
with:
script: |
const previewUrl = '${{ steps.deploy.outputs.url }}' || 'https://audius-web-preview.workers.dev';
const body = `## 🌐 Web preview ready

**Preview URL:** ${previewUrl}

Built from this PR. The preview is shared across PRs (latest deploy wins).
_[Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})_`;
const marker = '<!-- audius-web-preview -->';
const bodyWithMarker = body + '\n' + marker;
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 && c.body.includes(marker) && c.user.type === 'Bot');
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: bodyWithMarker
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: bodyWithMarker
});
}
env:
GH_TOKEN: ${{ github.token }}

web-check-ssr-bundlesize:
name: Web Check SSR Bundlesize
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions packages/web/src/ssr/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ vars = { SENTRY_DSN = "https://4db9c77b0bd7ae6a935f8bd58c06dad3@o260428.ingest.s
"https://api.audius.co"
] }

# Preview environment for PR deployments (GitHub Actions)
[env.preview]
name = "audius-web-ssr-preview"
vars = { DISCOVERY_NODE_ALLOWLIST = [
"https://api.audius.co"
] }

# Test environment, replace `test` with subdomain
# Invoke with npx wrangler dev --env test
[env.test]
Expand Down
9 changes: 9 additions & 0 deletions packages/web/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ services = [
]
vars = { ENVIRONMENT = "production", EMBED = "https://embed.audius.workers.dev", API_URL = "https://api.audius.co", DISCOVERY_NODES = "https://api.audius.co" }

# Preview environment for PR deployments (GitHub Actions)
# Deployed on every PR; single preview URL overwritten per build
[env.preview]
name = "audius-web-preview"
services = [
{ binding = "SSR", service = "audius-web-ssr-preview" }
]
vars = { ENVIRONMENT = "production", EMBED = "https://embed.audius.workers.dev", API_URL = "https://api.audius.co", DISCOVERY_NODES = "https://api.audius.co" }

# Test environment, replace `test` with subdomain
# Invoke with npx wrangler dev --env test
[env.test]
Expand Down
Loading