Skip to content

Commit 32900e3

Browse files
authored
fix: improve mount path check (#519)
* fix: refactor file path handling in HasChanged* functions for improved clarity * fix: add debug logging for commit comparison in deployment handlers * fix: refactor file change detection logic for improved clarity and accuracy * fix: update polling configuration for test branch and adjust interval * fix: add trigger event parameter to DeployStack and update related logic * fix: improve logging for mounted file changes and enhance error handling in project file checks * fix: enhance error handling in stack deployment tests * fix: check only in compose mode for file changes Swarm mode always force recreates stacks during deployment * fix: add dependency on proxy service in compose configuration
1 parent 3c92eb0 commit 32900e3

File tree

5 files changed

+169
-117
lines changed

5 files changed

+169
-117
lines changed

cmd/doco-cd/http_handler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ func HandleEvent(ctx context.Context, jobLog *slog.Logger, w http.ResponseWriter
363363
return
364364
}
365365

366+
subJobLog.Debug("comparing commits",
367+
slog.String("deployed_commit", deployedCommit),
368+
slog.String("latest_commit", latestCommit))
369+
366370
var changedFiles []git.ChangedFile
367371
if deployedCommit != "" {
368372
changedFiles, err = git.GetChangedFilesBetweenCommits(repo, plumbing.NewHash(deployedCommit), plumbing.NewHash(latestCommit))
@@ -396,7 +400,7 @@ func HandleEvent(ctx context.Context, jobLog *slog.Logger, w http.ResponseWriter
396400
}
397401

398402
err = docker.DeployStack(subJobLog, internalRepoPath, externalRepoPath, &ctx, &dockerCli, dockerClient,
399-
&payload, deployConfig, changedFiles, latestCommit, Version, false)
403+
&payload, deployConfig, changedFiles, latestCommit, Version, "webhook", false)
400404
if err != nil {
401405
onError(repoName, w, subJobLog.With(logger.ErrAttr(err)), "deployment failed", err.Error(), jobID, http.StatusInternalServerError)
402406

cmd/doco-cd/poll_handler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ func RunPoll(ctx context.Context, pollConfig config.PollConfig, appConfig *confi
417417
return fmt.Errorf("%w: %s: skipping deployment", ErrDeploymentConflict, deployConfig.Name)
418418
}
419419

420+
subJobLog.Debug("comparing commits",
421+
slog.String("deployed_commit", deployedCommit),
422+
slog.String("latest_commit", latestCommit))
423+
420424
if latestCommit == deployedCommit {
421425
subJobLog.Debug("no new commit found, skipping deployment", slog.String("last_commit", latestCommit))
422426

@@ -465,7 +469,7 @@ func RunPoll(ctx context.Context, pollConfig config.PollConfig, appConfig *confi
465469
}
466470

467471
err = docker.DeployStack(subJobLog, internalRepoPath, externalRepoPath, &ctx, &dockerCli, dockerClient,
468-
&payload, deployConfig, changedFiles, latestCommit, Version, false)
472+
&payload, deployConfig, changedFiles, latestCommit, Version, "poll", false)
469473
if err != nil {
470474
subJobLog.Error("failed to deploy stack", log.ErrAttr(err))
471475

dev.compose.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
x-poll-config: &poll-config
22
POLL_CONFIG: |
33
- url: https://github.com/kimdre/doco-cd_tests.git
4-
reference: main
5-
interval: 15
6-
target: "" # "test"
4+
reference: test
5+
interval: 10
6+
target: ""
77
private: true
88
99
services:
@@ -15,6 +15,8 @@ services:
1515
args:
1616
- APP_VERSION=dev
1717
restart: unless-stopped
18+
depends_on:
19+
- proxy
1820
ports:
1921
- "80:80"
2022
- "9120:9120"

0 commit comments

Comments
 (0)