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

Allow a version filter for Tomcat #855

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,13 @@ with:
```

### Tomcat Dependency
The Tomcat Dependency watches the [Apache Tomcat Download Page](https://downloads.apache.org/tomcat/tomcat-9/) for new versions.
The Tomcat Dependency watches the [Apache Tomcat Download Page](https://downloads.apache.org/tomcat/tomcat-9/) for new versions. An optional `version_regex` can be specified to filter on a specific minor versions. If set, the regex must include three capture groups. For example, `^v(10)\.(0)\.([\d]+)/$` to match `10.0.*`.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/tomcat-dependency:main
with:
uri: https://downloads.apache.org/tomcat/tomcat-9
version_regex: ^v([\d]+)\.([\d]+)\.([\d]+)/$
```

### Tomee Dependency
Expand Down
8 changes: 7 additions & 1 deletion actions/tomcat-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ func main() {
panic(fmt.Errorf("uri must be specified"))
}

versionRegex, ok := inputs["version_regex"]
if !ok {
fmt.Println(`No version_regex set, using default: ^v([\d]+)\.([\d]+)\.([\d]+)/$`)
versionRegex = `^v([\d]+)\.([\d]+)\.([\d]+)/$`
}

c := colly.NewCollector()

cp := regexp.MustCompile(`^v([\d]+)\.([\d]+)\.([\d]+)/$`)
cp := regexp.MustCompile(versionRegex)
versions := make(actions.Versions)
c.OnHTML("a[href]", func(element *colly.HTMLElement) {
if p := cp.FindStringSubmatch(element.Attr("href")); p != nil {
Expand Down