Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: trigger configuration changed detection for build settings

Andras Bacsai9452f0b4688f
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 821c69bcad..6e920f8e69 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -1035,7 +1035,7 @@ class Application extends BaseModel
public function isConfigurationChanged(bool $save = false)
{
- $newConfigHash = base64_encode($this->fqdn.$this->git_repository.$this->git_branch.$this->git_commit_sha.$this->build_pack.$this->static_image.$this->install_command.$this->build_command.$this->start_command.$this->ports_exposes.$this->ports_mappings.$this->custom_network_aliases.$this->base_directory.$this->publish_directory.$this->dockerfile.$this->dockerfile_location.$this->custom_labels.$this->custom_docker_run_options.$this->dockerfile_target_build.$this->redirect.$this->custom_nginx_configuration.$this->settings->use_build_secrets);
+ $newConfigHash = base64_encode($this->fqdn.$this->git_repository.$this->git_branch.$this->git_commit_sha.$this->build_pack.$this->static_image.$this->install_command.$this->build_command.$this->start_command.$this->ports_exposes.$this->ports_mappings.$this->custom_network_aliases.$this->base_directory.$this->publish_directory.$this->dockerfile.$this->dockerfile_location.$this->custom_labels.$this->custom_docker_run_options.$this->dockerfile_target_build.$this->redirect.$this->custom_nginx_configuration.$this->settings->use_build_secrets.$this->settings->inject_build_args_to_dockerfile.$this->settings->include_source_commit_in_build);
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
$newConfigHash .= json_encode($this->environment_variables()->get(['value', 'is_multiline', 'is_literal', 'is_buildtime', 'is_runtime'])->sort());
} else {
diff --git a/tests/Unit/ApplicationConfigurationChangeTest.php b/tests/Unit/ApplicationConfigurationChangeTest.php
index 618f3d033b..8ad88280b8 100644
--- a/tests/Unit/ApplicationConfigurationChangeTest.php
+++ b/tests/Unit/ApplicationConfigurationChangeTest.php
@@ -15,3 +15,35 @@ it('different custom_network_aliases values produce different hashes', function
->and($hash1)->not->toBe($hash3)
->and($hash2)->not->toBe($hash3);
});
+
+/**
+ * Unit test to verify that inject_build_args_to_dockerfile is included in configuration change detection.
+ * Tests the behavior of the isConfigurationChanged method by verifying that different
+ * inject_build_args_to_dockerfile values produce different configuration hashes.
+ */
+it('different inject_build_args_to_dockerfile values produce different hashes', function () {
+ // Test that the hash calculation includes inject_build_args_to_dockerfile by computing hashes with different values
+ // true becomes '1', false becomes '', so they produce different hashes
+ $hash1 = md5(base64_encode('test'.true)); // 'test1'
+ $hash2 = md5(base64_encode('test'.false)); // 'test'
+ $hash3 = md5(base64_encode('test')); // 'test'
+
+ expect($hash1)->not->toBe($hash2)
+ ->and($hash2)->toBe($hash3); // false and empty string produce the same result
+});
+
+/**
+ * Unit test to verify that include_source_commit_in_build is included in configuration change detection.
+ * Tests the behavior of the isConfigurationChanged method by verifying that different
+ * include_source_commit_in_build values produce different configuration hashes.
+ */
+it('different include_source_commit_in_build values produce different hashes', function () {
+ // Test that the hash calculation includes include_source_commit_in_build by computing hashes with different values
+ // true becomes '1', false becomes '', so they produce different hashes
+ $hash1 = md5(base64_encode('test'.true)); // 'test1'
+ $hash2 = md5(base64_encode('test'.false)); // 'test'
+ $hash3 = md5(base64_encode('test')); // 'test'
+
+ expect($hash1)->not->toBe($hash2)
+ ->and($hash2)->toBe($hash3); // false and empty string produce the same result
+});