forked from goeuropa/transitime-1
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
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,80 @@ | ||
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main", "v3-gradle" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
name: Checkout | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: Build with Gradle | ||
run: gradle clean build | ||
|
||
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive | ||
- name: Update dependency graph | ||
uses: mikepenz/gradle-dependency-submission@v1.0.06 | ||
|
||
container-image: | ||
if: github.repository_owner == 'opentransportro' && github.event_name == 'push' && (github.ref == 'refs/heads/main') | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
cache: gradle | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- name: Build container image with Jib, push to Dockerhub | ||
env: | ||
CONTAINER_REPO: docker.io/otrro/transitclock-server | ||
CONTAINER_REGISTRY_USER: ${{secrets.DOCKER_USER}} | ||
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_AUTH }} | ||
run: | | ||
# we give the container two tags | ||
# - "latest" | ||
# - a string like "2.3_2022-12-12T21-38" | ||
version_with_snapshot=`gradle properties -q | awk '/^version:/ {print $2}'` | ||
version=${version_with_snapshot/-SNAPSHOT/} | ||
|
||
image_version=${version} | ||
|
||
## if the Gradle version contains SNAPSHOT, then add date to tag | ||
if [[ $version_with_snapshot == *"SNAPSHOT"* ]]; then | ||
image_date=`date +%Y-%m-%dT%H-%M` | ||
image_version="${version}_${image_date}" | ||
echo "Gradle version ${version_with_snapshot} contains SNAPSHOT, adding date to container image tag" | ||
fi | ||
|
||
gradle build jib:jib -Djib.to.tags=latest,$image_version |