Skip to content

Commit

Permalink
fix for no versions found
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed Aug 21, 2024
1 parent 3c2b1f0 commit 3ddd69f
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions actions/jprofiler-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,40 @@ import (
"fmt"
"regexp"

"github.com/gocolly/colly"
"net/http"

"github.com/PuerkitoBio/goquery"
"github.com/paketo-buildpacks/pipeline-builder/actions"
)

func main() {
inputs := actions.NewInputs()

c := colly.NewCollector()

cp := regexp.MustCompile(`^Release ([\d]+)\.([\d]+)\.([\d]+).*$`)
versions := make(actions.Versions)
c.OnHTML("h5", func(element *colly.HTMLElement) {
if p := cp.FindStringSubmatch(element.Text); p != nil {

res, err := http.Get("https://www.ej-technologies.com/jprofiler/changelog")
if err != nil {
panic(err)
}
defer res.Body.Close()

doc, err := goquery.NewDocumentFromReader(res.Body)
if err != nil {
panic(err)
}

doc.Find("div.release-heading").Each(func(i int, s *goquery.Selection) {
if p := cp.FindStringSubmatch(s.Text()); p != nil {
v := fmt.Sprintf("%s.%s.%s", p[1], p[2], p[3])

versions[v] = fmt.Sprintf("https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_%s_%s_%s.tar.gz", p[1], p[2], p[3])
}
})

if err := c.Visit("https://www.ej-technologies.com/download/jprofiler/changelog.html"); err != nil {
panic(err)
}

if o, err := versions.GetLatest(inputs); err != nil {
panic(err)
} else {
o.Write()
}
}
}

0 comments on commit 3ddd69f

Please sign in to comment.