mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-15 16:34:49 +00:00
split assets to R2 bucket in cloudflare
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
This commit is contained in:
parent
ad9f65ffed
commit
d8703b75c8
4 changed files with 26 additions and 8 deletions
12
.github/workflows/deploy-cloudflare.yml
vendored
12
.github/workflows/deploy-cloudflare.yml
vendored
|
|
@ -22,9 +22,21 @@ jobs:
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
env:
|
env:
|
||||||
|
BASE_PATH: /
|
||||||
|
GAME_ASSETS_BASE_URL: https://assets.tribes2.online/game/base/
|
||||||
RELAY_URL: ${{ secrets.RELAY_URL }}
|
RELAY_URL: ${{ secrets.RELAY_URL }}
|
||||||
LOG_LEVEL: ${{ secrets.LOG_LEVEL }}
|
LOG_LEVEL: ${{ secrets.LOG_LEVEL }}
|
||||||
|
|
||||||
|
- name: Sync game assets to R2
|
||||||
|
run: aws s3 sync docs/base/ s3://t2-assets/game/base/ --follow-symlinks --delete
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ENDPOINT_URL: https://${{ secrets.CF_ACCOUNT_ID }}.r2.cloudflarestorage.com
|
||||||
|
|
||||||
|
- name: Remove game assets from Pages deploy
|
||||||
|
run: rm -rf docs/base
|
||||||
|
|
||||||
- uses: cloudflare/wrangler-action@v3
|
- uses: cloudflare/wrangler-action@v3
|
||||||
with:
|
with:
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
"build:manifest": "tsx --tsconfig tsconfig.node.json scripts/generate-manifest.ts -o src/manifest.json",
|
"build:manifest": "tsx --tsconfig tsconfig.node.json scripts/generate-manifest.ts -o src/manifest.json",
|
||||||
"build:parser": "peggy TorqueScript.pegjs -o generated/TorqueScript.js --format es",
|
"build:parser": "peggy TorqueScript.pegjs -o generated/TorqueScript.js --format es",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build:gh-pages": "BASE_PATH=/t2-mapper/ npm run build",
|
|
||||||
"copy-public": "cpy --dot 'public/*' '!(public/docs)' docs",
|
"copy-public": "cpy --dot 'public/*' '!(public/docs)' docs",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const log = createLogger("loaders");
|
||||||
|
|
||||||
export type { TerrainFile };
|
export type { TerrainFile };
|
||||||
|
|
||||||
export const RESOURCE_ROOT_URL = `${process.env.BASE_PATH}base/`;
|
export const RESOURCE_ROOT_URL = process.env.GAME_ASSETS_BASE_URL;
|
||||||
export const FALLBACK_TEXTURE_URL = `${process.env.BASE_PATH}white.png`;
|
export const FALLBACK_TEXTURE_URL = `${process.env.BASE_PATH}white.png`;
|
||||||
|
|
||||||
export function getUrlForPath(resourcePath: string, fallbackUrl?: string) {
|
export function getUrlForPath(resourcePath: string, fallbackUrl?: string) {
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,22 @@ export default defineConfig(({ mode }) => {
|
||||||
// Only expose specific env vars to the client bundle — loadEnv requires a
|
// Only expose specific env vars to the client bundle — loadEnv requires a
|
||||||
// prefix, so we load with each var's own prefix and pick the value out.
|
// prefix, so we load with each var's own prefix and pick the value out.
|
||||||
const allEnv = loadEnv(mode, process.cwd(), "");
|
const allEnv = loadEnv(mode, process.cwd(), "");
|
||||||
const basePath = allEnv.BASE_PATH || "/";
|
|
||||||
const publicEnvKeys = ["LOG_LEVEL", "RELAY_URL"];
|
const publicEnv: Record<string, string> = {
|
||||||
|
LOG_LEVEL: allEnv.LOG_LEVEL || "info",
|
||||||
|
RELAY_URL: allEnv.RELAY_URL || "wss://t2-relay.fly.dev",
|
||||||
|
BASE_PATH: allEnv.BASE_PATH || "/",
|
||||||
|
GAME_ASSETS_BASE_URL:
|
||||||
|
allEnv.GAME_ASSETS_BASE_URL || `${allEnv.BASE_PATH || "/"}base/`,
|
||||||
|
};
|
||||||
|
|
||||||
const define: Record<string, string> = {};
|
const define: Record<string, string> = {};
|
||||||
for (const key of publicEnvKeys) {
|
for (const key in publicEnv) {
|
||||||
define[`process.env.${key}`] = JSON.stringify(allEnv[key] ?? "");
|
define[`process.env.${key}`] = JSON.stringify(publicEnv[key]);
|
||||||
}
|
}
|
||||||
define["process.env.BASE_PATH"] = JSON.stringify(basePath);
|
|
||||||
return {
|
return {
|
||||||
base: basePath,
|
base: publicEnv.BASE_PATH,
|
||||||
server: { port: 3000 },
|
server: { port: 3000 },
|
||||||
define,
|
define,
|
||||||
build: {
|
build: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue