Skip to content

refactor: github action push test results #45

refactor: github action push test results

refactor: github action push test results #45

Workflow file for this run

name: Java Gradle Build and Test
on:
push:
branches:
- master
- staging
pull_request:
branches:
- master
- staging
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'corretto'
- name: Build and Test with Gradle
run: ./gradlew build
- name: Upload Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-results
path: sdk-java/build/reports/tests/
- name: Comment on PR with HTML Report Link
if: ${{ always() }}
uses: actions/github-script@v6
with:
script: |
const workspaceUrl = '${{ github.workspace }}/sdk-java/build/reports/tests/test/index.html'
const artifactLink = `<a href=${workspaceUrl}` target="_blank">HTML Test Report</a>`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Test report is available here: ${artifactLink}`,
});