Skip to content

feat: add CI workflow #1

feat: add CI workflow

feat: add CI workflow #1

Workflow file for this run

name: CI
on: [pull_request]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Decode and create application-test.properties
run: echo "${{ secrets.APPLICATION_TEST_PROPERTIES }}" | base64 --decode > src/main/resources/application-test.properties
- name: Extract MySQL credentials
id: mysql-credentials
run: |
DB_NAME=$(grep 'spring.datasource.url' src/main/resources/application-test.properties | cut -d'/' -f4)
DB_USER=$(grep 'spring.datasource.username' src/main/resources/application-test.properties | cut -d'=' -f2)
DB_PASSWORD=$(grep 'spring.datasource.password' src/main/resources/application-test.properties | cut -d'=' -f2)
echo "db_name=${DB_NAME}" >> $GITHUB_OUTPUT
echo "db_user=${DB_USER}" >> $GITHUB_OUTPUT
echo "db_password=${DB_PASSWORD}" >> $GITHUB_OUTPUT
- name: Setup MySQL
uses: mirromutth/mysql-action@master
with:
mysql database: ${{ steps.mysql-credentials.outputs.db_name }}
mysql user: ${{ steps.mysql-credentials.outputs.db_user }}
mysql password: ${{ steps.mysql-credentials.outputs.db_password }}
- name: Set up JDK 17
uses: actions/setup-java@main
with:
java-version: "17"
distribution: "adopt"
- name: Cache Maven packages
uses: actions/cache@main
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Build with Maven
run: mvn package
- name: Run tests
run: mvn test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@main
with:
token: ${{ secrets.CODECOV_TOKEN }}