Created
October 22, 2022 08:37
-
-
Save julienbourdeau/9f6e3bb520e7af3efad654d824dcde58 to your computer and use it in GitHub Desktop.
Show current Git hash (as version) with Laravel Blade component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\View\Components\Admin; | |
use Illuminate\Support\Facades\Cache; | |
use Illuminate\View\Component; | |
class GitDetails extends Component | |
{ | |
const REPO = 'julienbourdeau/julienbourdeau.com'; | |
public function render() | |
{ | |
$hash = Cache::remember('currentGitHash', 3600, fn() => exec('git rev-parse HEAD')); | |
$url = sprintf('https://github.com/%s/tree/%s', self::REPO, $hash); | |
return view('components.admin.git-details', [ | |
'hash' => $hash, | |
'url' => $url, | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment