Skip to content

Commit

Permalink
Merge pull request #73 from tanhongit/update-event-template
Browse files Browse the repository at this point in the history
Update push event template
  • Loading branch information
mytruong-z committed May 16, 2024
2 parents 852d69e + 6b27ec2 commit 8f7d665
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions lang/de/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
'by' => 'by',
'unknown_callback' => 'Unknown Callback. Something went wrong!',
'invalid_request' => 'Invalid Request!',
'branch' => 'Branch',
];
2 changes: 1 addition & 1 deletion lang/de/events/github/push.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
'default' => [
'title' => '👷⚙️ <b>:count</b> new :noun to 🦊<b>:repo:<code>:branch</code></b>',
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by',
],
Expand Down
1 change: 1 addition & 0 deletions lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
'by' => 'by',
'unknown_callback' => 'Unknown Callback. Something went wrong!',
'invalid_request' => 'Invalid Request!',
'branch' => 'Branch',
];
2 changes: 1 addition & 1 deletion lang/en/events/github/push.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
'default' => [
'title' => '👷⚙️ <b>:count</b> new :noun to 🦊<b>:repo:<code>:branch</code></b>',
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by',
],
Expand Down
1 change: 1 addition & 0 deletions lang/ja/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
'by' => 'by',
'unknown_callback' => 'Unknown Callback. Something went wrong!',
'invalid_request' => 'Invalid Request!',
'branch' => 'Branch',
];
2 changes: 1 addition & 1 deletion lang/ja/events/github/push.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
'default' => [
'title' => '👷⚙️ <b>:count</b> new :noun to 🦊<b>:repo:<code>:branch</code></b>',
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by',
],
Expand Down
7 changes: 4 additions & 3 deletions lang/vi/app.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

return [
'by' => 'bởi',
'unknown_callback' => 'Callback không xác định. Đã xảy ra lỗi!',
'invalid_request' => 'Yêu cầu không hợp lệ!',
'by' => 'by',
'unknown_callback' => 'Unknown Callback. Something went wrong!',
'invalid_request' => 'Invalid Request!',
'branch' => 'Branch',
];
2 changes: 1 addition & 1 deletion lang/vi/events/github/push.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
'default' => [
'title' => '👷⚙️ <b>:count</b> new :noun to 🦊<b>:repo:<code>:branch</code></b>',
'title' => '<b>:count</b> new :noun to <b>:repo:<code>:branch</code></b>',
'commit' => '[:commit] :commit_message - by <i>:commit_by</i>',
'pusher' => 'Pushed by',
],
Expand Down
12 changes: 10 additions & 2 deletions resources/views/events/github/push/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@
$ref = explode('/', $payload->ref);
$branch = implode('/', array_slice($ref, 2));
if (empty($payload->commits)) {
return '';
}
?>

{!! __('tg-notifier::events/github/push.default.title', [
👷⚙️ {!! __('tg-notifier::events/github/push.default.title', [
'count' => $count,
'noun' => $noun,
'repo' => $payload->repository->full_name,
'repo' => "🦑<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>",
'branch' => $branch,
]
) !!}

@foreach($payload->commits as $commit)
@php
$commitId = substr($commit->id, -7);
$commit->message = $commit->message ?? '';
$commit->message = explode("\n", $commit->message)[0];
@endphp
{!! __('tg-notifier::events/github/push.default.commit', [
'commit' => "<a href='$commit->url'>$commitId</a>",
Expand All @@ -30,4 +37,5 @@
) !!}
@endforeach

🌲 {{ __('tg-notifier::app.branch') }}: <code>{{ $branch }}</code>
👤 {!! __('tg-notifier::events/github/push.default.pusher') !!}: <code>{{ $payload->pusher->name }}</code>
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
{{ $icon }} {!! __("tg-notifier::events/github/workflow_job.completed.$status", ['repo' => "🦑<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}

🚀 {!! __('tg-notifier::events/github/workflow_job.name') !!}: {{ $icon }} <code>{{ $payload->workflow_job->name }}</code> {{ $last }}
🚨 {!! __('tg-notifier::events/github/workflow_job.status.title') !!}: <code>{!! __('tg-notifier::events/github/workflow_job.status.'.$status) !!}</code> 🕓 <code>{{ $allSeconds }}s</code>
🚨 {!! __('tg-notifier::events/github/workflow_job.status.title') !!}: <code>{!! __('tg-notifier::events/github/workflow_job.status.'.$status) !!}</code> ⏱️ <code>{{ $allSeconds }}s</code>
🔗 {!! __('tg-notifier::events/github/workflow_job.link', ['link' => "<a href='{$payload->workflow_job->html_url}'>{$payload->workflow_job->workflow_name}</a>"]) !!}
14 changes: 7 additions & 7 deletions routes/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

$routePrefix = config('telegram-git-notifier.defaults.route_prefix');

Route::prefix($routePrefix)->group(function () use ($routePrefix) {
Route::match(['get', 'post'], '/', IndexAction::class)->name("$routePrefix.index");
Route::prefix($routePrefix)->name("$routePrefix.")->group(function () {
Route::match(['get', 'post'], '/', IndexAction::class)->name('index');

Route::prefix('webhook')->group(function () use ($routePrefix) {
Route::get('set', [WebhookAction::class, 'set'])->name("$routePrefix.webhook.set");
Route::get('delete', [WebhookAction::class, 'delete'])->name("$routePrefix.webhook.delete");
Route::get('info', [WebhookAction::class, 'getWebHookInfo'])->name("$routePrefix.webhook.info");
Route::get('updates', [WebhookAction::class, 'getUpdates'])->name("$routePrefix.webhook.updates");
Route::prefix('webhook')->name('webhook.')->group(function () {
Route::get('set', [WebhookAction::class, 'set'])->name('set');
Route::get('delete', [WebhookAction::class, 'delete'])->name('delete');
Route::get('info', [WebhookAction::class, 'getWebHookInfo'])->name('info');
Route::get('updates', [WebhookAction::class, 'getUpdates'])->name('updates');
});
});

0 comments on commit 8f7d665

Please sign in to comment.