From 7e37aa35313ca5582a4ccced7b01016b2a923ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Tue, 14 May 2024 20:55:25 +0200 Subject: [PATCH 1/3] Add github workflow to build and deploy docker image to public registry --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..bfbae760 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI Build + +on: + push: + branches: + - github-workflow-publish +# pull_request: +# branches: +# - master + +jobs: + tests: + runs-on: ubuntu-latest + env: + TZ: Europe/Oslo + steps: + - uses: actions/checkout@v4 + + # nodejs is needed because the dynamic download of it via the prettier maven plugin often + # times out + # Example: https://github.com/opentripplanner/OpenTripPlanner/actions/runs/4490450225/jobs/7897533439 + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + cache: maven + + - name: Run tests + run: | + sudo timedatectl set-timezone "Europe/Oslo" + mvn --batch-mode jacoco:prepare-agent test jacoco:report -Dprettier.nodePath=node -Dprettier.npmPath=npm + mvn --batch-mode jib:dockerBuild -Dmaven.test.skip -P prettierSkip + + + image: + # only build and push the image when it's a commit to master in Entur's repository + if: github.repository_owner == 'entur' && github.event_name == 'push' + runs-on: ubuntu-latest + needs: [ tests ] + env: + CONTAINER_REPO: docker.io/entur/uttu + CONTAINER_REGISTRY_USER: ${{ secrets.DOCKERHUB_LOGIN }} + CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + cache: maven + + - name: Build container image with Jib, push to container repo + run: | + image_date=`date +%Y-%m-%dT%H-%M` + mvn --batch-mode compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_date -Dmaven.test.skip -P prettierSkip From 330ef67c7e6f750a4590592e0146dfd11d962370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Tue, 14 May 2024 22:33:18 +0200 Subject: [PATCH 2/3] Add jib-maven-plugin --- pom.xml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pom.xml b/pom.xml index 34d7e59c..84a4b8ba 100644 --- a/pom.xml +++ b/pom.xml @@ -483,6 +483,42 @@ + + com.google.cloud.tools + jib-maven-plugin + 3.4.2 + + + + com.google.cloud.tools + jib-spring-boot-extension-maven + 0.1.0 + + + + + bellsoft/liberica-openjdk-alpine:21.0.3-10 + + + ${env.CONTAINER_REPO} + + ${env.CONTAINER_REGISTRY_USER} + ${env.CONTAINER_REGISTRY_PASSWORD} + + + + + + 8080 + + + + + com.google.cloud.tools.jib.maven.extension.springboot.JibSpringBootExtension + + + + From dedea00100fdcdbca5c0a45cdf3e1381c519ec87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Erik=20St=C3=B8wer?= Date: Thu, 23 May 2024 14:13:40 +0200 Subject: [PATCH 3/3] Switch to master for running workflow --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfbae760..e93df56f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: CI Build on: push: branches: - - github-workflow-publish -# pull_request: -# branches: -# - master + - master + pull_request: + branches: + - master jobs: tests: