Skip to content

update the maven.yml #8

update the maven.yml

update the maven.yml #8

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Java CI with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ams
MYSQL_USER: admin
MYSQL_PASSWORD: root
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Set up JDK 19
uses: actions/setup-java@v4
with:
java-version: '19'
distribution: 'temurin'
cache: maven
- name: Wait for MySQL to be ready
run: |
echo "Waiting for MySQL to be ready..."
until mysqladmin ping -h 127.0.0.1 -u admin --password=root --silent; do
sleep 2
done
- name: Build with Maven
run: mvn clean install
- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: asadaaron/ams-backend
tags: latest
registry: docker.io
dockerfile: Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD}}