Skip to content

Gradle build workflow #22

Gradle build workflow

Gradle build workflow #22

Workflow file for this run

name: Gradle Build
on:
pull_request:
branches:
- develop
types:
- opened
- reopened
- synchronize
jobs:
gradle_build:
name: Gradle Build
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: dbtest
MYSQL_ROOT_PASSWORD: testrootpass
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Add Gradle wrapper permissions
run: chmod +x gradlew
- name: Test login to MySQL
run: mysql -h 127.0.0.1 -u dbuser -pdbpassword -e "SHOW DATABASES;"
- name: Set database variables
run: |
echo "spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dbtest?useUnicode=yes&characterEncoding=UTF-8
spring.datasource.username=dbuser
spring.datasource.password=dbpassword
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false
spring.jpa.properties.hibernate.jdbc.time_zone=UTC" > src/main/resources/application.properties
- name: Show database variables
run: cat src/main/resources/application.properties
- name: Build with Gradle
run: ./gradlew build