Merge remote-tracking branch 'origin/main' into chore/363-toolchain #1155
Workflow file for this run
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
# This workflow will build a Java project with Gradle | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | |
name: Java CI with Gradle | |
on: | |
push: | |
pull_request: | |
branches: [ master ] | |
schedule: | |
- cron: '20 15 * * 0' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Clone opensha fork | |
if: github.event.schedule != '20 15 * * 0' | |
uses: actions/checkout@v2 | |
with: | |
repository: GNS-Science/opensha | |
ref: fix/rup-normalization-2024 | |
path: opensha | |
- name: Clone opensha | |
if: github.event.schedule == '20 15 * * 0' | |
uses: actions/checkout@v2 | |
with: | |
repository: opensha/opensha | |
ref: master | |
path: opensha | |
- uses: actions/checkout@v2 | |
with: | |
path: main | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Build with Gradle | |
run: | | |
cd main | |
chmod +x gradlew | |
./gradlew check | |
./gradlew jacocoTestReport | |
- name: Add coverage to PR | |
id: jacoco | |
uses: GNS-Science/jacoco-report@c9acaa1b36f995c60841aaf1455420af1ddb8b9b | |
with: | |
paths: ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 40 | |
min-coverage-changed-files: 60 | |
title: Code Coverage | |
update-comment: true | |
# - name: Fail PR if overall coverage is less than 80% | |
# if: ${{ steps.jacoco.outputs.coverage-overall < 80.0 }} | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# core.setFailed('Overall coverage is less than 80%!') | |
- name: Set version env var | |
if: startsWith(github.ref, 'refs/tags/release') | |
run: echo "TAG_VERSION=$(echo ${{github.ref}} | cut -d'/' -f 4)" >> $GITHUB_ENV | |
- name: Set fatjar name | |
if: startsWith(github.ref, 'refs/tags/release') | |
run: echo "JAR_NAME=nzshm-opensha-all-${{env.TAG_VERSION}}.jar" >> $GITHUB_ENV | |
- name: Build FatJar with Gradle | |
if: startsWith(github.ref, 'refs/tags/release') | |
run: | | |
cd opensha | |
git rev-parse HEAD > ../main/src/main/resources/opensha-ref.txt | |
cd ../main | |
echo "${{env.TAG_VERSION}}" > src/main/resources/tagged-version.txt | |
chmod +x gradlew | |
./gradlew fatjar | |
mv build/libs/nzshm-opensha-all.jar build/libs/${{env.JAR_NAME}} | |
- uses: GNS-Science/s3-sync-action@master | |
with: | |
args: --acl public-read | |
if: startsWith(github.ref, 'refs/tags/release') | |
name: Upload to S3 | |
id: S3 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_AWS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_AWS_SECRET_ACCESS_KEY}} | |
AWS_S3_BUCKET: ${{ secrets.RELEASE_AWS_BUCKET }} | |
AWS_REGION: 'ap-southeast-2' | |
SOURCE_DIR: main/build/libs/ | |
destination_dir: '' |