Skip to content

Commit 443f561

Browse files
committed
add github action config, and maven jib plugin in pom
1 parent c50aca0 commit 443f561

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

.circleci/.github/workflows/ci.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
env:
15+
TZ: Europe/Oslo
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: 21
22+
distribution: temurin
23+
cache: maven
24+
25+
- name: Run tests
26+
run: |
27+
sudo timedatectl set-timezone "Europe/Oslo"
28+
mvn --batch-mode test
29+
30+
31+
image:
32+
# only build and push the image when it's a commit to master in Entur's repository
33+
if: github.repository_owner == 'entur' && github.event_name == 'push'
34+
runs-on: ubuntu-latest
35+
needs: [ tests ]
36+
env:
37+
CONTAINER_REPO: docker.io/entur/kishar
38+
CONTAINER_REGISTRY_USER: ${{ secrets.DOCKERHUB_LOGIN }}
39+
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up JDK 21
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: 21
47+
distribution: temurin
48+
cache: maven
49+
- name: set variables
50+
run: |
51+
echo "GHA_DOCKER_PUSH_IMAGE_TAG=`date +%Y-%m-%dT%H-%M`" >> $GITHUB_ENV
52+
53+
- name: Build container image with Jib, push to container repo
54+
run: |
55+
mvn --batch-mode compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,${{ env.GHA_DOCKER_PUSH_IMAGE_TAG }}
56+
57+
- name: Tag default branch with the container image tag ${{ env.GHA_DOCKER_PUSH_IMAGE_TAG }}
58+
id: tag-version
59+
run: |
60+
git config user.name github-actions[bot]
61+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
62+
git tag --annotate "$GHA_DOCKER_PUSH_IMAGE_TAG" -m "chore(tag): $GHA_DOCKER_PUSH_IMAGE_TAG [skip ci]" --force
63+
git push origin "$GHA_DOCKER_PUSH_IMAGE_TAG" --force

pom.xml

+36
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,42 @@
224224
</execution>
225225
</executions>
226226
</plugin>
227+
<plugin>
228+
<groupId>com.google.cloud.tools</groupId>
229+
<artifactId>jib-maven-plugin</artifactId>
230+
<version>3.4.2</version>
231+
<dependencies>
232+
<!-- Include jib-spring-boot-extension-maven to prevent spring-boot-devtools from being packaged.-->
233+
<dependency>
234+
<groupId>com.google.cloud.tools</groupId>
235+
<artifactId>jib-spring-boot-extension-maven</artifactId>
236+
<version>0.1.0</version>
237+
</dependency>
238+
</dependencies>
239+
<configuration>
240+
<from>
241+
<image>eclipse-temurin:21.0.1_12-jdk-alpine</image>
242+
</from>
243+
<to>
244+
<image>${env.CONTAINER_REPO}</image>
245+
<auth>
246+
<username>${env.CONTAINER_REGISTRY_USER}</username>
247+
<password>${env.CONTAINER_REGISTRY_PASSWORD}</password>
248+
</auth>
249+
</to>
250+
<container>
251+
<!-- Same as EXPOSE, doesn't actually publish the ports but acts as documentation -->
252+
<ports>
253+
<port>8777</port>
254+
</ports>
255+
</container>
256+
<pluginExtensions>
257+
<pluginExtension>
258+
<implementation>com.google.cloud.tools.jib.maven.extension.springboot.JibSpringBootExtension</implementation>
259+
</pluginExtension>
260+
</pluginExtensions>
261+
</configuration>
262+
</plugin>
227263
</plugins>
228264
</build>
229265

0 commit comments

Comments
 (0)