Commit 595103a

Eric Bower  ·  2026-05-08 09:27:28 -0400 EDT
parent bc114f5
fix: post receive hook
2 files changed,  +11, -3
+2, -2
......@@ -45,8 +45,8 @@ while read -r old_sha new_sha ref; do
4545 # Workspace points to the tar on pgs.sh
4646 workspace="${PGS_HOST}:${tar_path}"
4747
48- event=$(printf '{"type":"git.push","name":"%s","workspace":"%s","branch":"%s","commit":"%s","artifact_dest":"%s"}' \
49- "$repo" "$workspace" "$branch" "$new_sha" "$pgs_path")
48+ event=$(printf '{"type":"git.push","name":"%s","workspace":"%s","branch":"%s","commit":"%s","artifact_dest":"%s:%s"}' \
49+ "$repo" "$workspace" "$branch" "$new_sha" "$PGS_HOST" "$pgs_path")
5050
5151 log "publish: $event"
5252 echo "$event" | ssh -T "$PIPE_HOST" pub -b=false build.event
+9, -1
......@@ -1496,7 +1496,15 @@ func syncArtifacts(cfg *Cfg, log *slog.Logger) error {
14961496 cfg.CertificateLocation,
14971497 )
14981498 srcDir := filepath.Join(cfg.ArtifactDir, entry.Name(), repoEntry.Name())
1499- cmd := exec.Command("rsync", "-e", sshArgs, "-rv", srcDir+"/", event.ArtifactDest)
1499+ // Append "/" so rsync copies into the destination directory,
1500+ // not as a subdirectory named after the source.
1501+ dest := event.ArtifactDest
1502+ if !strings.HasSuffix(dest, "/") {
1503+ dest += "/"
1504+ }
1505+ rsyncCmd := fmt.Sprintf("rsync -e '%s' -rv %s/ %s", sshArgs, srcDir, dest)
1506+ log.Info("rsync", "cmd", rsyncCmd)
1507+ cmd := exec.Command("rsync", "-e", sshArgs, "-rv", srcDir+"/", dest)
15001508 if err := runCmd(cmd, log); err != nil {
15011509 log.Error("sync artifacts", "repo", entry.Name(), "job_id", repoEntry.Name(), "err", err)
15021510 }