Skip to content

Commit dd33793

Browse files
authored
fix error for jurisdication of bucket (#101)
1 parent 4947856 commit dd33793

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

packages/github-action/prepareDeploy.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,28 @@ workers_dev = true
5454
`;
5555
}
5656

57-
for (const bucket of R2EXPLORER_BUCKETS.split("\n")) {
58-
const split = bucket.trim().split(":");
59-
if (split.length !== 2) {
60-
console.error("R2EXPLORER_BUCKETS is not set correctly!");
61-
console.error(
62-
`"${split}" is not in the correct format => ALIAS:BUCKET_NAME`,
63-
);
64-
process.exit(1);
65-
}
57+
for (const rawBucket of R2EXPLORER_BUCKETS.split("\n")) {
58+
const bucket = rawBucket.trim();
59+
if (!bucket) continue; // skip empty lines
60+
const split = bucket.split(":");
61+
if (split.length !== 2 && split.length !== 3) {
62+
console.error("R2EXPLORER_BUCKETS is not set correctly!");
63+
console.error(`"${bucket}" is not in the correct format => ALIAS:BUCKET_NAME[:JURISDICTION]`);
64+
process.exit(1);
65+
}
6666

67-
wranglerConfig += `
67+
const [alias, bucketName, jurisdiction] = split;
68+
69+
wranglerConfig += `
6870
[[r2_buckets]]
69-
binding = '${split[0]}'
70-
bucket_name = '${split[1]}'
71-
preview_bucket_name = '${split[1]}'
71+
binding = '${alias}'
72+
bucket_name = '${bucketName}'
73+
preview_bucket_name = '${bucketName}'
74+
`;
75+
if (jurisdiction) {
76+
wranglerConfig += `jurisdiction = '${jurisdiction}'
7277
`;
78+
}
7379
}
7480

7581
console.log(wranglerConfig);

0 commit comments

Comments
 (0)