deploy: fix

This commit is contained in:
E. S. 2025-05-15 20:33:36 +03:00
parent 15e8f55ea4
commit a2ec3c1087
2 changed files with 12 additions and 4 deletions

View File

@ -25,5 +25,8 @@ done
for project in ic foreignone; do
"$SCRIPT_DIR"/util/build_css.sh -i "$APP_DIR/public/$project/scss" -o "$OUTPUT_ROOT_DIR/public/$project/dist-css" || die "build_css failed"
"$SCRIPT_DIR"/util/build_js.sh -i "$APP_DIR/public/common/js" -o "$OUTPUT_ROOT_DIR/public/$project/dist-js" || die "build_js failed"
$PHP "$SCRIPT_DIR"/util/gen_runtime_config.php --commit-hash "$(git rev-parse --short=8 HEAD)" > "$OUTPUT_ROOT_DIR/config-runtime.php" || die "gen_runtime_config failed"
$PHP "$SCRIPT_DIR"/util/gen_runtime_config.php \
--app-root "$OUTPUT_ROOT_DIR" \
--commit-hash "$(git rev-parse --short=8 HEAD)" \
> "$OUTPUT_ROOT_DIR/config-runtime.php" || die "gen_runtime_config failed"
done

View File

@ -4,18 +4,23 @@
require __DIR__.'/../../src/init.php';
$commit_hash = null;
$app_root = null;
for ($i = 1; $i < $argc; $i++) {
switch ($argv[$i]) {
case '--commit-hash':
$commit_hash = $argv[++$i] ?? usage('missing value for --commit-hash');
break;
case '--app-root':
$app_root = $argv[++$i] ?? usage('missing value for --app-root');
break;
default:
usage("unknown option {$argv[$i]}");
}
}
if (is_null($commit_hash))
if (is_null($commit_hash) || is_null($app_root))
usage();
$hashes = [
@ -25,7 +30,7 @@ $hashes = [
foreach (['ic', 'foreignone'] as $project) {
foreach (['js', 'css'] as $type) {
$dist_dir = APP_ROOT.'/public/'.$project.'/dist-'.$type;
$dist_dir = $app_root.'/public/'.$project.'/dist-'.$type;
$entries = glob_recursive($dist_dir.'/*.'.$type);
if (empty($entries)) {
fwrite(STDERR, "warning: no files found in $dist_dir\n");
@ -49,7 +54,7 @@ function usage(string $msg = ''): never {
if ($msg !== '')
fwrite(STDERR, "error: {$msg}\n");
$script = $GLOBALS['argv'][0];
fwrite(STDERR, "usage: {$script} --commit-hash HASH\n");
fwrite(STDERR, "usage: {$script} --commit-hash HASH --app-root APP_ROOT\n");
exit(1);
}