Skip to content

V2.2

V2.2 #148

Workflow file for this run

# This workflow will generate javadocs, build, and test a package using Maven
name: build
on:
pull_request:
branches:
- master
jobs:
get_javadocs_status:
name: get-javadocs-status
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 10 # important for use of HEAD^2
# find the last commit message on the source branch
- name: Get last commit message
shell: bash
run: echo "##[set-output name=commitMsg;]$(git log --format=%B -n 1 HEAD^2)"
id: extract_message
outputs:
# create an output that tells the following jobs whether or not we need to generate javadocs
generate_javadocs: ${{ steps.extract_message.outputs.commitMsg != '--- auto-generation of javadocs ---' }}
publish-javadocs:
needs: get_javadocs_status
# only run this if we have not generated javadocs in last commit
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
# extract the PR source branch name from the env variable where we can use it later
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF#refs/heads/})"
id: extract_branch
# generate the javadocs into the target/site/apidocs folder (default)
- name: Generate javadocs with Maven
run: mvn javadoc:javadoc
# publish the generated javadocs into the /docs folder on a new commit in this branch
- name: Publish javadocs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: ${{ steps.extract_branch.outputs.branch }}
folder: target/site/apidocs
target-folder: docs
git-config-name: Continuous Integration
git-config-email: devs@sovren.com
commit-message: --- auto-generation of javadocs ---
token: ${{ secrets.JAVADOCS_CI_TOKEN }}
build:
needs: get_javadocs_status
# only run this if we have already generated javadocs in last commit
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B compile --file pom.xml
unit-tests:
needs: get_javadocs_status
runs-on: ubuntu-latest
# only run this if we have already generated javadocs in last commit
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }}
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Create credentials file
run: 'echo "$CREDENTIALS_FILE" > ./src/test/resources/credentials.json'
shell: bash
env:
CREDENTIALS_FILE: ${{secrets.TEST_CREDENTIALS}}
- name: Test with Maven
run: mvn test --fail-at-end --file pom.xml
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1