-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to build and publish a Docker container (#11)
- Loading branch information
Showing
7 changed files
with
203 additions
and
8 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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
# 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: CI Github | ||
name: Build | ||
|
||
on: | ||
push: | ||
|
@@ -23,4 +20,4 @@ jobs: | |
- name: Build with Maven | ||
run: mvn -B package --file pom.xml | ||
- name: Codecov | ||
uses: codecov/[email protected] | ||
uses: codecov/[email protected] |
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,120 @@ | ||
# yamllint disable rule:line-length | ||
--- | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
packages: write | ||
contents: write | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JAVA 8 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 8 | ||
distribution: "temurin" | ||
|
||
- name: Determine the version | ||
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | ||
id: versioncheck | ||
|
||
- name: Exit when workflow_dispatch is triggered, and the version does not contain SNAPSHOT in it's name | ||
run: | | ||
echo "Only SNAPSHOT releases can be triggered with the workflow_dispatch" | ||
exit 1 | ||
if: github.event_name == 'workflow_dispatch' && ( !endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) | ||
|
||
- name: Exit when a production build is triggered, and the github tag is not the same as the version in pom.xml | ||
run: | | ||
echo echo "Project version ${{ steps.versioncheck.outputs.version }} does not match git tag ${{ github.ref_name }}" | ||
exit 1 | ||
if: github.event_name != 'workflow_dispatch' && steps.versioncheck.outputs.version != github.ref_name | ||
|
||
- name: Set up JDK 8 for snapshots | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "8" | ||
distribution: "temurin" | ||
cache: "maven" | ||
server-id: openconext-snapshots | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
if: ( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) | ||
|
||
- name: Set up JDK 8 for releases | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "8" | ||
distribution: "temurin" | ||
cache: "maven" | ||
server-id: openconext-releases | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
if: ${{!( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) }} | ||
|
||
- name: Deploy with Maven | ||
run: mvn --batch-mode deploy -DskipTests | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.BUILD_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.BUILD_PASSWORD }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set docker labels and tags | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/surfnet/student-mobility-home-institution-mock/home-institution-mock | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=ref,event=tag | ||
type=raw,value=latest,event=tag | ||
type=semver,pattern={{version}},value=${{ steps.versioncheck.outputs.version }} | ||
type=sha | ||
- name: Build and push the docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Codecov | ||
uses: codecov/[email protected] | ||
|
||
- name: Create release | ||
uses: actions/create-release@v1 | ||
id: create_release | ||
with: | ||
draft: false | ||
prerelease: true | ||
release_name: Release ${{ github.ref_name }} | ||
tag_name: ${{ github.ref_name }} | ||
body: | | ||
${{ steps.changelog.outputs.changelog }} | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
if: github.event_name != 'workflow_dispatch' |
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,3 @@ | ||
FROM eclipse-temurin:8-jdk-alpine | ||
COPY target/*.jar app.jar | ||
ENTRYPOINT ["java","-jar","/app.jar"] |
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,65 @@ | ||
logging: | ||
level: | ||
root: warn | ||
home: debug | ||
org.springframework: info | ||
|
||
delay: | ||
enabled: true | ||
millis-association: 1 | ||
millis-offering: 1 | ||
millis-person: 1 | ||
|
||
server: | ||
port: 8076 | ||
|
||
security: | ||
user: | ||
name: user | ||
password: secret | ||
|
||
spring: | ||
mail: | ||
host: localhost | ||
port: 3025 | ||
security: | ||
oauth2: | ||
resourceserver: | ||
opaque-token: | ||
introspection-uri: https://connect.test2.surfconext.nl/oidc/introspect | ||
# introspection-uri: http://localhost:8081/introspect | ||
client-id: student.mobility.home.institution.mock.local | ||
client-secret: secret | ||
|
||
email: | ||
from: [email protected] | ||
|
||
# used by the git plugin | ||
info: | ||
build: | ||
artifact: "@project.artifactId@" | ||
version: "@project.version@" | ||
|
||
management: | ||
endpoints: | ||
enabled-by-default: false | ||
web: | ||
exposure: | ||
include: | ||
- health | ||
- info | ||
base-path: "/internal" | ||
endpoint: | ||
health: | ||
enabled: true | ||
show-details: when_authorized | ||
info: | ||
enabled: true | ||
health: | ||
mail: | ||
enabled: false | ||
info: | ||
git: | ||
mode: full | ||
defaults: | ||
enabled: true |
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,10 @@ | ||
# yamllint disable rule:line-length | ||
--- | ||
version: '3.8' | ||
services: | ||
intekenontvanger-generiek: | ||
image: ghcr.io/surfnet/student-mobility-home-institution-mock/home-institution-mock:latest | ||
volumes: | ||
- ${PWD}/application.yml:/application.yml | ||
ports: | ||
- 8092:8092 |
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