Skip to content

Upgrade to Spring Boot 3 (#141) #35

Upgrade to Spring Boot 3 (#141)

Upgrade to Spring Boot 3 (#141) #35

Workflow file for this run

name: Build
on: [push, pull_request]
env:
MAVEN_OPTS: -Xms64m -Xmx512m
MAVEN_CLI_OPTS: -s .mvn/settings.xml -B -Dfrontend-build -Ddocker-build
MAVEN_GOALS: clean verify
DOCKER_REGISTRY: ghcr.io
DOCKER_REPO: ${{ github.repository_owner }}
DOCKER_IMAGE: karaplan
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: temurin
cache: maven
settings-path: ${{ github.workspace }}/.mvn
- name: Build webapp
run: mvn ${MAVEN_CLI_OPTS} ${MAVEN_GOALS} -DskipTests
- name: Test webapp
run: mvn ${MAVEN_CLI_OPTS} test
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: webapp
path: target/karaplan.war
- name: Publish artifacts
if: startsWith(github.ref, 'refs/tags')
run: mvn ${MAVEN_CLI_OPTS} deploy -DskipTests
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Login to Docker registry
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build Docker image
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
run: docker build -t "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}" target/docker-build
- name: Publish Docker image
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
run: |
docker push "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}"
if [ "${{ github.ref_type }}" != "tag" ]; then
DOCKER_TAG="${{ github.ref_name }}-$(date +'%Y%m%d-%H%M')-$(echo ${{ github.sha }} | head -c 7)"
docker tag "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}" "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}"
docker push "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}"
fi