feat: add GitHub event handling and pull request title display
All checks were successful
Lint Pull Request / Lint Pr Title (pull_request) Successful in 9s

This commit is contained in:
Jan K9f 2025-04-09 18:17:12 +02:00
parent 2c943b845f
commit 044823552b
Signed by: jank
GPG key ID: B9F475106B20F144

39
main.go
View file

@ -1,16 +1,39 @@
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
// Get all environment variables
environ := os.Environ()
// Print each environment variable
for _, env := range environ {
fmt.Println(env)
}
type GithubEvent struct {
PullRequest struct {
Title string `json:"title"`
} `json:"pull_request"`
}
func main() {
eventPath := os.Getenv("GITHUB_EVENT_PATH")
if eventPath == "" {
fmt.Println("GITHUB_EVENT_PATH not set")
os.Exit(1)
}
eventFile, err := os.Open(eventPath)
if err != nil {
fmt.Printf("Error opening %s: %v\n", eventPath, err)
os.Exit(1)
}
defer eventFile.Close()
var event GithubEvent
decoder := json.NewDecoder(eventFile)
err = decoder.Decode(&event)
if err != nil {
fmt.Printf("Error decoding event.json: %v\n", err)
os.Exit(1)
}
prTitle := event.PullRequest.Title
fmt.Println("Pull Request Title:", prTitle)
}