Add support for action artifact serve direct (#29120)

Fixes #29093

(cherry picked from commit 07597c71a4b6642beae7589c678603f4846f7920)
This commit is contained in:
KN4CK3R 2024-02-15 21:39:50 +01:00 committed by Earl Warren
parent 7474f62857
commit 1f8ad34e43
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -63,6 +63,7 @@ package actions
import (
"crypto/md5"
"errors"
"fmt"
"net/http"
"strconv"
@ -426,7 +427,19 @@ func (ar artifactRoutes) getDownloadArtifactURL(ctx *ArtifactContext) {
var items []downloadArtifactResponseItem
for _, artifact := range artifacts {
downloadURL := ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
var downloadURL string
if setting.Actions.ArtifactStorage.MinioConfig.ServeDirect {
u, err := ar.fs.URL(artifact.StoragePath, artifact.ArtifactName)
if err != nil && !errors.Is(err, storage.ErrURLNotSupported) {
log.Error("Error getting serve direct url: %v", err)
}
if u != nil {
downloadURL = u.String()
}
}
if downloadURL == "" {
downloadURL = ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
}
item := downloadArtifactResponseItem{
Path: util.PathJoinRel(itemPath, artifact.ArtifactPath),
ItemType: "file",