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 | |
| 45 | 45 | # Workspace points to the tar on pgs.sh | |
| 46 | 46 | workspace="${PGS_HOST}:${tar_path}" | |
| 47 | 47 | ||
| 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") | |
| 50 | 50 | ||
| 51 | 51 | log "publish: $event" | |
| 52 | 52 | echo "$event" | ssh -T "$PIPE_HOST" pub -b=false build.event |
M
main.go
+9,
-1
| ... | ... | @@ -1496,7 +1496,15 @@ func syncArtifacts(cfg *Cfg, log *slog.Logger) error { | |
| 1496 | 1496 | cfg.CertificateLocation, | |
| 1497 | 1497 | ) | |
| 1498 | 1498 | 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) | |
| 1500 | 1508 | if err := runCmd(cmd, log); err != nil { | |
| 1501 | 1509 | log.Error("sync artifacts", "repo", entry.Name(), "job_id", repoEntry.Name(), "err", err) | |
| 1502 | 1510 | } |