-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add matrix subcommand + move bot to check
- Loading branch information
Showing
13 changed files
with
553 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/sethvargo/go-githubactions" | ||
) | ||
|
||
// Recursively search for nested values using the keys provided. | ||
func IndexMap(m map[string]any, keys ...string) any { | ||
if len(keys) == 0 { | ||
return m | ||
} | ||
|
||
if val, ok := m[keys[0]]; ok { | ||
if keys = keys[1:]; len(keys) == 0 { | ||
return val | ||
} | ||
subMap, _ := val.(map[string]any) | ||
return IndexMap(subMap, keys...) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// Retrieve PR number from GitHub Actions context | ||
func GetPRNumFromActionsCtx(actionCtx *githubactions.GitHubContext) (int, error) { | ||
firstKey := "" | ||
|
||
switch actionCtx.EventName { | ||
case EventIssueComment: | ||
firstKey = "issue" | ||
case EventPullRequest, EventPullRequestTarget: | ||
firstKey = "pull_request" | ||
default: | ||
return 0, fmt.Errorf("unsupported event: %s", actionCtx.EventName) | ||
} | ||
|
||
num, ok := IndexMap(actionCtx.Event, firstKey, "number").(float64) | ||
if !ok || num <= 0 { | ||
return 0, fmt.Errorf("invalid value: %d", int(num)) | ||
} | ||
|
||
return int(num), nil | ||
} |
Oops, something went wrong.