database #45
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 | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 8 * * *" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-and-test: | |
name: Test and Build | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:20.10.7 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven | |
- name: Set timezone | |
run: | | |
export TZ=America/Los_Angeles | |
- name: Setup Maven settings | |
run: | | |
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml | |
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml | |
- 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 Docker | |
run: | | |
echo "ACCESS_TOKEN=$(gcloud auth print-access-token)" >> $GITHUB_ENV | |
- name: Docker login to Artifact Registry | |
run: echo "${{ env.ACCESS_TOKEN }}" | docker login -u oauth2accesstoken --password-stdin https://us-west1-docker.pkg.dev | |
- name: Test and Build with Maven | |
run: | | |
mvn -e -Dmaven.javadoc.skip=true \ | |
"-Duser.timezone=America/Los_Angeles" \ | |
"-Dhsqldb.database.url=jdbc:hsqldb:file:target/hsqldb;shutdown=true" \ | |
-Dhsqldb.database.user=SA -Dhsqldb.database.password= -Pcoverage,hsqldb verify && | |
bash test-postgres.sh | |
- name: Display Surefire reports on failure | |
if: failure() | |
run: | | |
for F in target/surefire-reports/*.txt; do echo $F; cat $F; echo; done | |
deploy-snapshots: | |
name: Deploy Snapshots | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven | |
- name: Setup Maven settings | |
run: | | |
cp ./travis/actions-maven-settings.xml $HOME/.m2/settings.xml | |
sed -i "s/-SNAPSHOT/-github-build-${{ github.run_number }}/" pom.xml | |
- 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: Deploy to Maven | |
run: mvn --batch-mode -e -DskipTests=true deploy |