Skip to content

added github actions workflow #2

added github actions workflow

added github actions workflow #2

name: database-goodies
on:
push:
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:9.6
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Maven settings
run: |
mkdir -p ~/.m2
cp ./travis/maven-settings.xml ~/.m2/settings.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Create test database and user in PostgreSQL
run: |
psql -U postgres -c "create user test with password 'test';"
psql -c 'create database test owner test;' -U postgres
env:
PGPASSWORD: postgres
- name: Run tests
run: |
mvn -e test
mvn -e -Ppostgresql -Dpostgres.database.url=jdbc:postgresql:test \
-Dpostgres.database.user=test -Dpostgres.database.password=test verify
- name: Print Surefire reports on failure
if: failure()
run: |
echo "\n=== SUREFIRE REPORTS ===\n"
for F in target/surefire-reports/*.txt; do echo $F; cat $F; echo; done
deploy_snapshots:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Set up Maven settings
run: |
mkdir -p ~/.m2
cp ./travis/maven-settings.xml ~/.m2/settings.xml
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml
- name: Deploy Snapshots
run: |
mvn --batch-mode -e -DskipTests=true deploy