Add go-githubactions dependency

This commit is contained in:
Daniel Cosme
2026-02-13 14:31:56 -05:00
parent 08625a8c08
commit 8d02620a0b
3 changed files with 8 additions and 28 deletions

2
go.mod
View File

@@ -1,3 +1,5 @@
module git.danicos.dev/actions/simple-go-action module git.danicos.dev/actions/simple-go-action
go 1.25.6 go 1.25.6
require github.com/sethvargo/go-githubactions v1.3.2

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/sethvargo/go-githubactions v1.3.2 h1:gkibLr/QjosgNWoCf1V58rTMRZw7xZtSB7dY4atbl1Y=
github.com/sethvargo/go-githubactions v1.3.2/go.mod h1:7/4WeHgYfSz9U5vwuToCK9KPnELVHAhGtRwLREOQV80=

32
main.go
View File

@@ -4,37 +4,13 @@ import (
"fmt" "fmt"
"os" "os"
"time" "time"
ga "github.com/sethvargo/go-githubactions"
) )
func main() { func main() {
username := readInputs() username := ga.GetInput("username")
fmt.Printf("username is %s\n", username) fmt.Printf("username is %s\n", username)
err := writeOutputs("time", time.Now().Format("2006-01-02 15:04:05")) ga.SetOutput("time", time.Now().Format("2006-01-02 15:04:05"))
if err != nil {
panic(err)
}
}
func readInputs() string {
username := os.Getenv("INPUT_USERNAME")
return username
}
func writeOutputs(k, v string) (err error) {
msg := fmt.Sprintf("%s=%s", k, v)
outputFilepath := os.Getenv("GITHUB_OUTPUT")
f, err := os.OpenFile(outputFilepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return
}
defer func() {
if cErr := f.Close(); cErr != nil && err == nil {
err = cErr
}
}()
if _, err = f.Write([]byte(msg)); err != nil {
return
}
return
} }