JOJ3/cmd/joj3/env/env.go
张泊明518370910136 e4e7445645
All checks were successful
submodules sync / sync (push) Successful in 47s
build / build (push) Successful in 1m41s
build / trigger-build-image (push) Successful in 9s
feat(cmd/joj3): support actor csv
2024-11-18 00:18:01 -05:00

42 lines
866 B
Go

package env
import (
"fmt"
"os"
"time"
)
type Attribute struct {
ConfName string
RunID string
Actor string
Repository string
Sha string
Ref string
Workflow string
RunNumber string
ActorName string
ActorID string
}
var Attr Attribute
func init() {
timestamp := time.Now().UnixNano()
pid := os.Getpid()
high := timestamp >> 32
low := timestamp & 0xFFFFFFFF
combined := high ^ low
combined ^= int64(pid)
combined ^= int64(timestamp >> 16)
combined ^= (combined >> 8)
combined ^= (combined << 16)
Attr.RunID = fmt.Sprintf("%08X", combined&0xFFFFFFFF)
Attr.Actor = os.Getenv("GITHUB_ACTOR")
Attr.Repository = os.Getenv("GITHUB_REPOSITORY")
Attr.Sha = os.Getenv("GITHUB_SHA")
Attr.Ref = os.Getenv("GITHUB_REF")
Attr.Workflow = os.Getenv("GITHUB_WORKFLOW")
Attr.RunNumber = os.Getenv("GITHUB_RUN_NUMBER")
}