-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tomee-dependency action to track apache-tomee
- Loading branch information
1 parent
d2852d4
commit a0c5b6f
Showing
4 changed files
with
143 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Create Action tomee-dependency | ||
"on": | ||
pull_request: | ||
paths: | ||
- actions/* | ||
- actions/tomee-dependency/* | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- actions/* | ||
- actions/tomee-dependency/* | ||
release: | ||
types: | ||
- published | ||
jobs: | ||
create-action: | ||
name: Create Action | ||
runs-on: | ||
- ubuntu-latest | ||
steps: | ||
- name: Docker login ghcr.io | ||
if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} | ||
uses: docker/login-action@v1 | ||
with: | ||
password: ${{ secrets.JAVA_GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
username: ${{ secrets.JAVA_GITHUB_USERNAME }} | ||
- uses: actions/checkout@v2 | ||
- name: Create Action | ||
run: | | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "::group::Building ${TARGET}:${VERSION}" | ||
docker build \ | ||
--file actions/Dockerfile \ | ||
--build-arg "SOURCE=${SOURCE}" \ | ||
--tag "${TARGET}:${VERSION}" \ | ||
. | ||
echo "::endgroup::" | ||
if [[ "${PUSH}" == "true" ]]; then | ||
echo "::group::Pushing ${TARGET}:${VERSION}" | ||
docker push "${TARGET}:${VERSION}" | ||
echo "::endgroup::" | ||
else | ||
echo "Skipping push" | ||
fi | ||
env: | ||
PUSH: ${{ github.event_name != 'pull_request' }} | ||
SOURCE: tomee-dependency | ||
TARGET: ghcr.io/paketo-buildpacks/actions/tomee-dependency | ||
VERSION: main |
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,76 @@ | ||
/* | ||
* Copyright 2018-2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
|
||
"github.com/gocolly/colly" | ||
|
||
"github.com/paketo-buildpacks/pipeline-builder/actions" | ||
) | ||
|
||
var TomeeVersionPattern = regexp.MustCompile(`^tomee-?([\d]+)\.?([\d]+)?\.?([\d]+)?[-+.]?(.*)/$`) | ||
|
||
func main() { | ||
inputs := actions.NewInputs() | ||
|
||
uri, ok := inputs["uri"] | ||
if !ok { | ||
panic(fmt.Errorf("uri must be specified")) | ||
} | ||
|
||
dist, ok := inputs["dist"] | ||
if !ok { | ||
dist = "webprofile" | ||
} | ||
|
||
major, ok := inputs["major"] | ||
if !ok { | ||
major = "" | ||
} | ||
|
||
c := colly.NewCollector() | ||
|
||
versions := make(actions.Versions) | ||
c.OnHTML("a[href]", func(element *colly.HTMLElement) { | ||
if p := TomeeVersionPattern.FindStringSubmatch(element.Attr("href")); p != nil { | ||
if major == "" || major == p[1] { | ||
v := fmt.Sprintf("%s.%s.%s", p[1], p[2], p[3]) | ||
if p[4] != "" { | ||
v = fmt.Sprintf("%s-%s", v, p[4]) | ||
} | ||
|
||
versions[v] = fmt.Sprintf("%s/tomee-%[2]s/apache-tomee-%[2]s-%s.tar.gz", uri, v, dist) | ||
|
||
fmt.Println("Adding", v, "with url", versions[v]) | ||
} | ||
} | ||
}) | ||
|
||
if err := c.Visit(uri); err != nil { | ||
panic(err) | ||
} | ||
|
||
if o, err := versions.GetLatest(inputs); err != nil { | ||
panic(err) | ||
} else { | ||
o.Write(os.Stdout) | ||
} | ||
} |