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
99 changes: 99 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- 'packages/web/**'
- 'packages/embed/**'
- 'packages/common/**'
- 'packages/harmony/**'
- 'packages/libs/**'
Expand All @@ -15,6 +16,7 @@ on:
pull_request:
paths:
- 'packages/web/**'
- 'packages/embed/**'
- 'packages/common/**'
- 'packages/harmony/**'
- 'packages/libs/**'
Expand Down Expand Up @@ -915,6 +917,103 @@ jobs:
json_content="{ \"blocks\": [{ \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"Deployed production <${job_url}|v${deploying_version}> to web \n\" } }]}"
curl -f -X POST -H 'Content-type: application/json' --data "$json_content" $SLACK_WEBHOOK

# Ported from the CircleCI `embed-deploy-production-cloudflare` job, which was
# dropped with the rest of .circleci in #14504 and never replaced - leaving the
# embed player with no deploy path at all. Unlike the old job (which only ran
# on release* branches) this deploys straight from main, and unlike the web
# deploy it isn't behind the production gate: the embed is a self-contained
# player with no desktop/S3 half to coordinate with.
embed-deploy:
name: Embed Deploy
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Upgrade npm to 11.10.0
run: npm install -g npm@11.10.0

- name: Create concatenated patch file
id: patch-file
run: |
ls -d -- packages/*/patches/*.patch 2>/dev/null | xargs cat > combined-patch-file.txt || touch combined-patch-file.txt
echo "patch_checksum=$(sha256sum combined-patch-file.txt | cut -d' ' -f1)" >> $GITHUB_OUTPUT

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
packages/embed/node_modules
packages/harmony/node_modules
packages/common/node_modules
packages/libs/node_modules
packages/sdk/node_modules
key: npm-cache-${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-${{ steps.patch-file.outputs.patch_checksum }}
restore-keys: |
npm-cache-${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-

- name: Install dependencies (if cache miss)
if: steps.cache-node-modules.outputs.cache-hit != 'true'
env:
CI: true
SKIP_POD_INSTALL: true
SKIP_ANDROID_INSTALL: true
ANDROID_HOME: /tmp/android-sdk-dummy
NODE_OPTIONS: --max-old-space-size=8192
run: |
mkdir -p /tmp/android-sdk-dummy
npm cache clean --force || true
npm ci --prefer-offline || npm install --prefer-offline

- name: Run postinstall (if cache hit)
if: steps.cache-node-modules.outputs.cache-hit == 'true'
env:
CI: true
SKIP_POD_INSTALL: true
SKIP_ANDROID_INSTALL: true
ANDROID_HOME: /tmp/android-sdk-dummy
NODE_OPTIONS: --max-old-space-size=8192
run: |
mkdir -p /tmp/android-sdk-dummy
npm run postinstall

# `build:prod` runs turbo, which builds the harmony/sdk dists first, then
# renames build/ to build-production/.
- name: Build embed
env:
NODE_OPTIONS: --max-old-space-size=8192
run: |
cd packages/embed
npm run build:prod

- name: Install workers-site dependencies
run: |
cd packages/embed/workers-site
npm i

# wrangler.toml's [site] bucket points at ./build, so undo the rename that
# build:prod just did. The old CircleCI job did exactly this - the split
# is why `build:prod && deploy:prod` deploys nothing on its own.
- name: Move build
run: |
cd packages/embed
mv build-production build

- name: Deploy to Cloudflare (Production)
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
cd packages/embed
npm_config_yes=true npx wrangler@4.54.0 deploy --env production

# Desktop (Electron) builds. electron-builder reads packages/web/build-production
# directly (see packages/web/scripts/dist.js), so the `builds` artifact is
# downloaded in place and not renamed.
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "vite build",
"build:prod": "env-cmd -f .env.prod turbo run build && npm run build-api && mv build build-production",
"build-api": "webpack --config src/api/webpack.config.js -o build/api.js",
"deploy:prod": "npx wrangler publish --env production",
"deploy:prod": "wrangler deploy --env production",
"test": "jest",
"lint:fix": "eslint --cache --fix --ext=js,jsx,ts,tsx src",
"lint": "eslint --cache --ext=js,jsx,ts,tsx src",
Expand Down
8 changes: 5 additions & 3 deletions packages/embed/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
compatibility_date = "2023-11-06"
type = "webpack"
account_id = "3811365464a8e56b2b27a5590e328e49"
workers_dev = true

# `main` replaces the old `[site] entry-point`, and the wrangler-1.x
# `type = "webpack"` field is gone - wrangler bundles the worker itself now.
main = "workers-site/index.js"

[site]
bucket = "./build"
entry-point = "workers-site"

[env.test]
name = "test"
route = "test.audius.co/*"

[env.production]
name = "embed"
route = "embed.audius.co/*"
route = "embed.audius.co/*"
Loading