added supported git lfs

This commit is contained in:
pasha1coil 2025-04-10 13:31:44 +03:00
parent 49f17fef28
commit b4f693a00f
2 changed files with 17 additions and 2 deletions

@ -30,6 +30,10 @@ inputs:
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
required: false
default: true
lfs:
description: 'Supported lfs module or not'
required: false
default: false
runs:
using: 'go'

@ -17,10 +17,9 @@ type Config struct {
CheckoutType CheckoutType
FetchDepth string
Clean bool
LFS bool
}
// todo lfs
type CheckoutType string
const (
@ -41,6 +40,12 @@ func getConfig() Config {
cleanBool = false
}
lfs := os.Getenv("INPUT_LFS")
lfsBool := false
if lfs == "1" || lfs == "true" || lfs == "t" {
lfsBool = true
}
return Config{
Repository: os.Getenv("INPUT_REPOSITORY"),
Ref: os.Getenv("INPUT_REF"),
@ -50,6 +55,7 @@ func getConfig() Config {
CheckoutType: CheckoutType(os.Getenv("INPUT_CHECKOUTTYPE")),
FetchDepth: fetchDepth,
Clean: cleanBool,
LFS: lfsBool,
}
}
@ -88,6 +94,11 @@ func main() {
run("git", "-C", cfg.Path, "fetch", fmt.Sprintf("--depth=%s", cfg.FetchDepth), "origin", cfg.Ref)
run("git", "-C", cfg.Path, "checkout", "FETCH_HEAD")
}
if cfg.LFS {
run("git", "-C", cfg.Path, "lfs", "install", "--local")
run("git", "-C", cfg.Path, "lfs", "pull")
}
}
func run(name string, args ...string) {