Skip to content

Commit 6dd6725

Browse files
ChristopherHXmergify[bot]
andauthoredJan 28, 2024
fix: improve new-action-cache fetch failure error (#2172)
- include repoURL and repoRef in error - map NoErrAlreadyUptodate to `couldn't find remote ref` for branchOrtag fetch request Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 09d4b5d commit 6dd6725

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎pkg/runner/action_cache.go

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"crypto/rand"
77
"encoding/hex"
88
"errors"
9+
"fmt"
910
"io"
1011
"io/fs"
1112
"path"
@@ -86,6 +87,9 @@ func (c GoGitActionCache) Fetch(ctx context.Context, cacheDir, url, ref, token s
8687
Auth: auth,
8788
Force: true,
8889
}); err != nil {
90+
if tagOrSha && errors.Is(err, git.NoErrAlreadyUpToDate) {
91+
return "", fmt.Errorf("couldn't find remote ref \"%s\"", ref)
92+
}
8993
return "", err
9094
}
9195
if tagOrSha {

‎pkg/runner/step_action_remote.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
6868

6969
var err error
7070
sar.cacheDir = fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo)
71-
sar.resolvedSha, err = cache.Fetch(ctx, sar.cacheDir, sar.remoteAction.URL+"/"+sar.cacheDir, sar.remoteAction.Ref, github.Token)
71+
repoURL := sar.remoteAction.URL + "/" + sar.cacheDir
72+
repoRef := sar.remoteAction.Ref
73+
sar.resolvedSha, err = cache.Fetch(ctx, sar.cacheDir, repoURL, repoRef, github.Token)
7274
if err != nil {
73-
return err
75+
return fmt.Errorf("failed to fetch \"%s\" version \"%s\": %w", repoURL, repoRef, err)
7476
}
7577

7678
remoteReader := func(ctx context.Context) actionYamlReader {

0 commit comments

Comments
 (0)
Please sign in to comment.