Skip to content

Commit

Permalink
updates tomcat action with sources output (#1302)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan authored Sep 27, 2023
1 parent d5490b6 commit 9a6d32a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions actions/tomcat-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,34 @@ func main() {

cp := regexp.MustCompile(versionRegex)
versions := make(actions.Versions)
sources := make(map[string]string)

c.OnHTML("a[href]", func(element *colly.HTMLElement) {
if p := cp.FindStringSubmatch(element.Attr("href")); p != nil {
v := fmt.Sprintf("%s.%s.%s", p[1], p[2], p[3])

versions[v] = fmt.Sprintf("%s/v%[2]s/bin/apache-tomcat-%[2]s.tar.gz", uri, v)
sources[v] = fmt.Sprintf("%s/v%[2]s/src/apache-tomcat-%[2]s-src.tar.gz", uri, v)
}
})

if err := c.Visit(uri); err != nil {
panic(err)
}

if o, err := versions.GetLatest(inputs); err != nil {
latestVersion, err := versions.GetLatestVersion(inputs)
if err != nil {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
latestSource["source"] = sources[latestVersion.Original()]
}

o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource)
if err != nil {
panic(err)
} else {
}else {
o.Write()
}
}

0 comments on commit 9a6d32a

Please sign in to comment.