Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #111: Amazon Corretto actions adds source #1322

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions actions/amazon-corretto-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
func main() {
inputs := actions.NewInputs()

r, ok := inputs["repository"]
repo, ok := inputs["repository"]
if !ok {
panic(fmt.Errorf("repository must be specified"))
}
Expand All @@ -56,14 +56,15 @@ func main() {
gh := github.NewClient(c)

versions := make(actions.Versions)
sources := make(map[string]string)

md := regexp.MustCompile(`(?U)\[(.+)]\((.+)\)`)

opt := &github.ListOptions{PerPage: 100}
for {
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "corretto", r, opt)
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "corretto", repo, opt)
if err != nil {
panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", "corretto", r, err))
panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", "corretto", repo, err))
}

for _, r := range rel {
Expand All @@ -86,6 +87,7 @@ func main() {
}

versions[s] = p[2]
sources[s] = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s.tar.gz", "corretto", repo, *r.TagName)
}
}
}
Expand All @@ -103,7 +105,12 @@ func main() {
panic(fmt.Errorf("unable to get latest version\n%w", err))
}

outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil)
latestSource := actions.Outputs{}
if sources != nil {
latestSource["source"] = sources[latestVersion.Original()]
}

outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource)
if err != nil {
panic(fmt.Errorf("unable to create outputs\n%w", err))
}
Expand Down
Loading