Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #26 from nlnwa/ci
Browse files Browse the repository at this point in the history
Use Github Actions CI
  • Loading branch information
maeb authored Jan 10, 2022
2 parents 882bee9 + 931f61f commit 86f4813
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 100 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Release

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

permissions:
contents: read
packages: write

jobs:
release:
name: Build and publish docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Cache maven repository
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Extract metadata (tags, labels) and establish version
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
sep-labels: ","

- name: Log in to the container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish docker image
run: |
mvn --batch-mode test jib:build \
-Djib.to.image="${REGISTRY}/${IMAGE_NAME}:${{ steps.meta.outputs.version }}" \
-Djib.container.labels="${{ steps.meta.outputs.labels }}"
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit tests

on:
pull_request: { }

permissions:
contents: read

jobs:
java_unit_tests:
name: Java unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Cache Maven repository
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Run tests
run: mvn --batch-mode test
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
target/
**/pom.xml.tag
**/pom.xml.releaseBackup
**/pom.xml.versionsBackup
**/pom.xml.next
**/release.properties
**/dependency-reduced-pom.xml
**/buildNumber.properties
**/nbproject/*


# IDEA
*.iml
Expand Down
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<extension>
<groupId>fr.brouillard.oss</groupId>
<artifactId>jgitver-maven-plugin</artifactId>
<version>1.5.1</version>
<version>1.9.0</version>
</extension>
</extensions>

Expand Down
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .travis/build_script.sh

This file was deleted.

11 changes: 0 additions & 11 deletions .travis/push_script.sh

This file was deleted.

57 changes: 8 additions & 49 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<docker.tag>${project.version}</docker.tag>

<log4j.version>2.17.1</log4j.version>
</properties>
Expand All @@ -45,7 +44,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>1.7.32</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -88,68 +87,47 @@
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.3</version>
<version>1.4.1</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>

<build>

<resources>
<resource>
<directory>src/main/jib/app/resources</directory>
</resource>
</resources>

<plugins>
<!-- Make version number available for application -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.6.0</version>
<version>3.1.4</version>
<configuration>
<to>
<image>docker.io/norsknettarkiv/${project.artifactId}</image>
<tags>
<tag>${docker.tag}</tag>
</tags>
<auth>
<username>${env.DOCKER_USERNAME}</username>
<password>${env.DOCKER_PASSWORD}</password>
</auth>
<image>${project.artifactId}:${project.version}</image>
</to>
<container>
<ports>
Expand Down Expand Up @@ -184,24 +162,5 @@
</plugins>
</build>
</profile>
<profile>
<id>docker-build-and-push</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 86f4813

Please sign in to comment.