Update ci.yml #5
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
name: CI Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
MYSQL_DATABASE: smartcontact | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Ensure wait-for-it.sh is executable | |
run: chmod +x ./wait-for-it.sh | |
- name: Wait for MySQL to be ready | |
run: ./wait-for-it.sh localhost:3306 --timeout=60 --strict -- echo "MySQL is up" | |
- name: Run tests | |
run: mvn test | |
- name: Package Spring Boot application as WAR | |
run: mvn package | |
- name: Upload Spring Boot application WAR | |
uses: actions/upload-artifact@v3 | |
with: | |
name: smartcontact-app | |
path: target/*.war |