diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e91ad61 --- /dev/null +++ b/action.yml @@ -0,0 +1,14 @@ +name: 'Simple Go Action' +description: 'A simple Gitea action written in go' +inputs: + username: + description: 'The username to print' + required: true +outputs: + time: + description: 'The time when the action was called' +runs: + using: 'go' + main: 'main.go' + pre: "pre/pre.go" + post: "post/post.go" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f21da09 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module simple-go-action + +go 1.20 + +require github.com/sethvargo/go-githubactions v1.1.0 + +require github.com/sethvargo/go-envconfig v0.8.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..bc57a6d --- /dev/null +++ b/go.sum @@ -0,0 +1,5 @@ +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/sethvargo/go-envconfig v0.8.0 h1:AcmdAewSFAc7pQ1Ghz+vhZkilUtxX559QlDuLLiSkdI= +github.com/sethvargo/go-envconfig v0.8.0/go.mod h1:Iz1Gy1Sf3T64TQlJSvee81qDhf7YIlt8GMUX6yyNFs0= +github.com/sethvargo/go-githubactions v1.1.0 h1:mg03w+b+/s5SMS298/2G6tHv8P0w0VhUFaqL1THIqzY= +github.com/sethvargo/go-githubactions v1.1.0/go.mod h1:qIboSF7yq2Qnaw2WXDsqCReM0Lo1gU4QXUWmhBC3pxE= diff --git a/main.go b/main.go new file mode 100644 index 0000000..1eefaef --- /dev/null +++ b/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "time" + + gha "github.com/sethvargo/go-githubactions" +) + +func main() { + username := gha.GetInput("username") + fmt.Printf("username is %s\n", username) + + gha.SetOutput("time", time.Now().Format("2006-01-02 15:04:05")) +} diff --git a/post/post.go b/post/post.go new file mode 100644 index 0000000..c15cdb4 --- /dev/null +++ b/post/post.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Post of Simple Go Action") +} diff --git a/pre/pre.go b/pre/pre.go new file mode 100644 index 0000000..b8d5edd --- /dev/null +++ b/pre/pre.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Pre of Simple Go Action") +}