database-goodies #121
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: database-goodies | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 8 * * *" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Oracle JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: 'zulu' | |
cache: maven | |
- name: Copy Maven settings | |
run: | | |
mkdir -p $HOME/.m2 | |
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml | |
- name: Update pom.xml version | |
run: | | |
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml | |
- name: Install PostgreSQL 14 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y postgresql-14 postgresql-contrib | |
- name: Configure PostgreSQL for trust authentication | |
run: | | |
sudo sed -i "s/peer/trust/" /etc/postgresql/14/main/pg_hba.conf | |
sudo sed -i "s/scram-sha-256/trust/" /etc/postgresql/14/main/pg_hba.conf | |
sudo service postgresql restart | |
- name: Set up PostgreSQL | |
run: | | |
sudo service postgresql start | |
sudo -u postgres psql -c "create user test;" | |
sudo -u postgres psql -c "create database test owner test;" | |
- 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: Show test 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.repository == 'susom/database-goodies' && github.ref == 'refs/heads/master' && github.event_name == 'push' | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
project_id: ${{ secrets.WORKLOAD_IDENTITY_PROJECT }} | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
create_credentials_file: true | |
export_environment_variables: true | |
cleanup_credentials: true | |
- name: Set up OAuth2 access token for Maven | |
run: | | |
echo "ACCESS_TOKEN=$(gcloud auth print-access-token)" >> $GITHUB_ENV | |
- name: Set up Oracle JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: 'zulu' | |
cache: maven | |
- name: Copy Maven settings | |
run: | | |
mkdir -p $HOME/.m2 | |
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml | |
- name: Update pom.xml version | |
run: | | |
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml | |
- name: Deploy snapshots | |
run: | | |
mvn --batch-mode -e -DskipTests=true deploy |