ci: extract Java version from .tool-versions in workflows #87
This file contains hidden or 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 will check Source code for Duplicate Blocks of Code | |
| name: Duplicate Blocks 37 Tokens | |
| on: | |
| push: | |
| branches: [ main, proceeding, betterment ] | |
| pull_request: | |
| branches: [ main, proceeding, betterment ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract Java version from .tool-versions | |
| id: java-version | |
| run: | | |
| TOOL_VERSION=$(grep '^java' .tool-versions | awk '{print $2}') | |
| JAVA_DIST=$(echo $TOOL_VERSION | cut -d'-' -f1) | |
| JAVA_VERSION=$(echo $TOOL_VERSION | cut -d'-' -f2) | |
| echo "distribution=$JAVA_DIST" >> $GITHUB_OUTPUT | |
| echo "version=$JAVA_VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up JDK from .tool-versions | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ steps.java-version.outputs.version }} | |
| distribution: ${{ steps.java-version.outputs.distribution }} | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Run checkstyle on Source and Test | |
| run: ./gradlew cpdCheck | |