Use hashed uses string as cache dir name (#117)

Reviewed-on: https://gitea.com/gitea/act/pulls/117
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Jason Song
2024-09-24 06:53:41 +00:00
parent 2ab806053c
commit 38e7e9e939
4 changed files with 49 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package model
import (
"crypto/sha256"
"fmt"
"io"
"reflect"
@@ -8,9 +9,10 @@ import (
"strconv"
"strings"
"github.com/nektos/act/pkg/common"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"github.com/nektos/act/pkg/common"
)
// Workflow is the structure of the files in .github/workflows
@@ -716,6 +718,12 @@ func (s *Step) Type() StepType {
return StepTypeUsesActionRemote
}
// UsesHash returns a hash of the uses string.
// For Gitea.
func (s *Step) UsesHash() string {
return fmt.Sprintf("%x", sha256.Sum256([]byte(s.Uses)))
}
// ReadWorkflow returns a list of jobs for a given workflow file reader
func ReadWorkflow(in io.Reader) (*Workflow, error) {
w := new(Workflow)