Skip to content

Commit 6676c6b

Browse files
authored
Merge branch 'coollabsio:main' into new-pull-request-template
2 parents 3b6c360 + e42c7e2 commit 6676c6b

28 files changed

+241
-187
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Remove Labels and Assignees on Issue Close
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
pull_request:
7+
types: [closed]
8+
pull_request_target:
9+
types: [closed]
10+
11+
jobs:
12+
remove-labels-and-assignees:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Remove labels and assignees
16+
uses: actions/github-script@v7
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
script: |
20+
const { owner, repo } = context.repo;
21+
22+
async function processIssue(issueNumber) {
23+
try {
24+
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
25+
owner,
26+
repo,
27+
issue_number: issueNumber
28+
});
29+
30+
const labelsToKeep = currentLabels
31+
.filter(label => label.name === '⏱︎ Stale')
32+
.map(label => label.name);
33+
34+
await github.rest.issues.setLabels({
35+
owner,
36+
repo,
37+
issue_number: issueNumber,
38+
labels: labelsToKeep
39+
});
40+
41+
const { data: issue } = await github.rest.issues.get({
42+
owner,
43+
repo,
44+
issue_number: issueNumber
45+
});
46+
47+
if (issue.assignees && issue.assignees.length > 0) {
48+
await github.rest.issues.removeAssignees({
49+
owner,
50+
repo,
51+
issue_number: issueNumber,
52+
assignees: issue.assignees.map(assignee => assignee.login)
53+
});
54+
}
55+
} catch (error) {
56+
if (error.status !== 404) {
57+
console.error(`Error processing issue ${issueNumber}:`, error);
58+
}
59+
}
60+
}
61+
62+
if (context.eventName === 'issues' || context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
63+
const issue = context.payload.issue || context.payload.pull_request;
64+
await processIssue(issue.number);
65+
}
66+
67+
if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
68+
const { data: closedIssues } = await github.rest.search.issuesAndPullRequests({
69+
q: `repo:${owner}/${repo} is:issue is:closed linked:${context.payload.pull_request.number}`,
70+
per_page: 100
71+
});
72+
for (const issue of closedIssues.items) {
73+
await processIssue(issue.number);
74+
}
75+
}

app/Jobs/PullHelperImageJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function handle(): void
4242
$current_version = $settings->helper_version;
4343
if (version_compare($latest_version, $current_version, '>')) {
4444
// New version available
45-
$helperImage = config('coolify.helper_image');
46-
instant_remote_process(["docker pull -q {$helperImage}:{$latest_version}"], $this->server);
45+
// $helperImage = config('coolify.helper_image');
46+
// instant_remote_process(["docker pull -q {$helperImage}:{$latest_version}"], $this->server);
4747
$settings->update(['helper_version' => $latest_version]);
4848
}
4949
}

app/Livewire/Project/Service/Navbar.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Navbar extends Component
2020

2121
public $isDeploymentProgress = false;
2222

23+
public $title = 'Configuration';
24+
2325
public function mount()
2426
{
2527
if (str($this->service->status())->contains('running') && is_null($this->service->config_hash)) {

app/Livewire/Project/Shared/ExecuteContainerCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class ExecuteContainerCommand extends Component
3333

3434
public function mount()
3535
{
36+
if (! auth()->user()->isAdmin()) {
37+
abort(403);
38+
}
3639
$this->parameters = get_route_parameters();
3740
$this->containers = collect();
3841
$this->servers = collect();
@@ -130,7 +133,6 @@ public function connectToContainer()
130133
{
131134
try {
132135
$container_name = data_get($this->container, 'container.Names');
133-
ray($this->container);
134136
if (is_null($container_name)) {
135137
throw new \RuntimeException('Container not found.');
136138
}

app/Livewire/Project/Shared/Terminal.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ public function sendTerminalCommand($isContainer, $identifier, $serverUuid)
1414

1515
$server = Server::ownedByCurrentTeam()->whereUuid($serverUuid)->firstOrFail();
1616

17-
// if (auth()->user()) {
18-
// $teams = auth()->user()->teams->pluck('id');
19-
// if (! $teams->contains($server->team_id) && ! $teams->contains(0)) {
20-
// throw new \Exception('User is not part of the team that owns this server');
21-
// }
22-
// }
23-
2417
if ($isContainer) {
2518
$status = getContainerStatus($server, $identifier);
2619
if ($status !== 'running') {

app/Livewire/RunCommand.php

Lines changed: 0 additions & 101 deletions
This file was deleted.

app/Livewire/Terminal/Index.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,70 @@
33
namespace App\Livewire\Terminal;
44

55
use App\Models\Server;
6+
use Livewire\Attributes\On;
67
use Livewire\Component;
78

89
class Index extends Component
910
{
11+
public $selected_uuid = 'default';
12+
1013
public $servers = [];
1114

15+
public $containers = [];
16+
1217
public function mount()
1318
{
19+
if (! auth()->user()->isAdmin()) {
20+
abort(403);
21+
}
1422
$this->servers = Server::isReachable()->get();
23+
$this->containers = $this->getAllActiveContainers();
24+
}
25+
26+
private function getAllActiveContainers()
27+
{
28+
return collect($this->servers)->flatMap(function ($server) {
29+
if (! $server->isFunctional()) {
30+
return [];
31+
}
32+
33+
return $server->loadAllContainers()->map(function ($container) use ($server) {
34+
$state = data_get_str($container, 'State')->lower();
35+
if ($state->contains('running')) {
36+
return [
37+
'name' => data_get($container, 'Names'),
38+
'connection_name' => data_get($container, 'Names'),
39+
'uuid' => data_get($container, 'Names'),
40+
'status' => data_get_str($container, 'State')->lower(),
41+
'server' => $server,
42+
'server_uuid' => $server->uuid,
43+
];
44+
}
45+
46+
return null;
47+
})->filter();
48+
});
49+
}
50+
51+
public function updatedSelectedUuid()
52+
{
53+
$this->connectToContainer();
54+
}
55+
56+
#[On('connectToContainer')]
57+
public function connectToContainer()
58+
{
59+
if ($this->selected_uuid === 'default') {
60+
$this->dispatch('error', 'Please select a server or a container.');
61+
62+
return;
63+
}
64+
$container = collect($this->containers)->firstWhere('uuid', $this->selected_uuid);
65+
$this->dispatch('send-terminal-command',
66+
isset($container),
67+
$container['connection_name'] ?? $this->selected_uuid,
68+
$container['server_uuid'] ?? $this->selected_uuid
69+
);
1570
}
1671

1772
public function render()

app/Models/Server.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function setupDynamicProxyConfiguration()
413413
handle /app/* {
414414
reverse_proxy coolify-realtime:6001
415415
}
416-
handle /terminal/ws/* {
416+
handle /terminal/ws {
417417
reverse_proxy coolify-realtime:6002
418418
}
419419
reverse_proxy coolify:80
@@ -775,6 +775,18 @@ public function getContainersWithSentinel(): Collection
775775
}
776776
}
777777

778+
public function loadAllContainers(): Collection
779+
{
780+
if ($this->isFunctional()) {
781+
$containers = instant_remote_process(["docker ps -a --format '{{json .}}'"], $this);
782+
$containers = format_docker_command_output_to_json($containers);
783+
784+
return collect($containers);
785+
}
786+
787+
return collect([]);
788+
}
789+
778790
public function loadUnmanagedContainers(): Collection
779791
{
780792
if ($this->isFunctional()) {

bootstrap/helpers/shared.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,11 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
29852985
// Get magic environments where we need to preset the FQDN
29862986
if ($key->startsWith('SERVICE_FQDN_')) {
29872987
// SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000
2988-
$fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value();
2988+
if (substr_count(str($key)->value(), '_') === 3) {
2989+
$fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value();
2990+
} else {
2991+
$fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value();
2992+
}
29892993
if ($isApplication) {
29902994
$fqdn = generateFqdn($server, "{$resource->name}-$uuid");
29912995
} elseif ($isService) {

config/sentry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// The release version of your application
99
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
10-
'release' => '4.0.0-beta.337',
10+
'release' => '4.0.0-beta.341',
1111
// When left empty or `null` the Laravel environment will be used
1212
'environment' => config('app.env'),
1313

0 commit comments

Comments
 (0)