1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00

feat: use hashed uses string as cache dir name (#186)

Port of https://gitea.com/gitea/act/pulls/117

Refs forgejo/act#100

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/186
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
earl-warren 2025-07-21 21:08:46 +00:00
parent 13ed94f5b7
commit a157d24741
4 changed files with 49 additions and 6 deletions

View file

@ -1,9 +1,12 @@
package model
import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"io"
"path/filepath"
"reflect"
"regexp"
"strconv"
@ -734,6 +737,12 @@ func (s *Step) Type() StepType {
return StepTypeUsesActionRemote
}
func (s *Step) UsesHash() string {
hashBytes := sha256.Sum256([]byte(s.Uses))
hashString := hex.EncodeToString(hashBytes[:])
return filepath.Join(hashString[:2], hashString[2:])
}
// ReadWorkflow returns a list of jobs for a given workflow file reader
func ReadWorkflow(in io.Reader, validate bool) (*Workflow, error) {
if validate {