Skip to content

A self-hosted media server and file management system

fix: .git folders aren't fetched when building docker file on github actions

aminnausin0b4bcdd82d56
diff --git a/.github/workflows/ci-docker-release.yml b/.github/workflows/ci-docker-release.yml
index 658801f8..46aff19e 100644
--- a/.github/workflows/ci-docker-release.yml
+++ b/.github/workflows/ci-docker-release.yml
@@ -199,6 +199,8 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
- name: Prepare default data files for release
run: |
diff --git a/Dockerfile b/Dockerfile
index 46d24003..a09beca1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -124,7 +124,7 @@ RUN composer dump-autoload && \
git config --global --add safe.directory /var/www/html && \
php artisan app:manifest && \
echo "--- Manifest contents ---" && \
- cat storage/app/public/manifest.json && \
+ cat public/manifest.json && \
echo "--- Git HEAD ---" && \
git rev-parse --short HEAD || echo "Git not working" && \
rm -rf .git && \
diff --git a/app/Console/Commands/GenerateManifest.php b/app/Console/Commands/GenerateManifest.php
index acf6239b..13b19053 100644
--- a/app/Console/Commands/GenerateManifest.php
+++ b/app/Console/Commands/GenerateManifest.php
@@ -11,8 +11,13 @@ class GenerateManifest extends Command {
protected $description = 'Generate the current Git version and commit hash to a manifest';
public function handle() {
- $version = trim(shell_exec('git describe --tags --abbrev=0')) ?: '0.0.0';
- $commit = trim(shell_exec('git rev-parse --short HEAD')) ?: 'unknown';
+ $commit = trim(shell_exec('git rev-parse --short HEAD') ?? '')
+ ?: substr(env('GITHUB_SHA', ''), 0, 7)
+ ?: 'unknown';
+
+ $version = trim(shell_exec('git describe --tags --abbrev=0') ?? '')
+ ?: (file_exists(base_path('VERSION')) ? trim(file_get_contents(base_path('VERSION'))) : null)
+ ?: env('GITHUB_REF_NAME', 'unknown');
$data = json_encode([
'version' => $version,
@@ -21,11 +26,15 @@ class GenerateManifest extends Command {
'laravel_version' => app()->version(),
'os' => php_uname('s') . ' ' . php_uname('v'),
'cpu_arch' => php_uname('m'),
- 'cpu_cores' => shell_exec('nproc') ?: 'unknown',
+ 'cpu_cores' => trim(shell_exec('nproc') ?? '') ?: 'unknown',
], JSON_PRETTY_PRINT);
- File::put(public_path('manifest.json'), $data);
-
- $this->info("App manifest generated: $version ($commit)");
+ try {
+ File::put(public_path('manifest.json'), json_encode($data, JSON_PRETTY_PRINT));
+ $this->info("App manifest generated: $version ($commit)");
+ } catch (\Throwable $e) {
+ $this->error("❌ Failed to write manifest: " . $e->getMessage());
+ return Command::FAILURE;
+ }
}
}