ci: sanitize environment variables for PR SHA and number (#207) #675
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
| name: Java CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: '*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: wagoid/commitlint-github-action@v6 | |
| - name: Set up JDK 1.8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: corretto | |
| java-version: 8 | |
| cache: maven | |
| - name: Build | |
| run: mvn -U -ntp clean verify | |
| - name: Upload Coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Coverage Report | |
| path: target/jacoco-report | |
| - name: Convert Jacoco to Cobertura | |
| run: python3 .github/scripts/cover2cover.py target/jacoco-report/jacoco.xml src/main/java > target/jacoco-report/cobertura.xml | |
| - name: Save PR number | |
| env: | |
| PR_NR: ${{ github.event.number }} | |
| PR_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| mkdir -p ./pr/jacoco-report | |
| SANITIZED_NR=$(echo "$PR_NR" | tr -cd '0-9') | |
| SANITIZED_SHA=$(echo "$PR_SHA" | tr -cd 'a-fA-F0-9') | |
| echo "$SANITIZED_NR" > ./pr/NR | |
| echo "$SANITIZED_SHA" > ./pr/SHA | |
| cp target/jacoco-report/cobertura.xml ./pr/jacoco-report/cobertura.xml | |
| if: github.event_name == 'pull_request' | |
| - name: Upload files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr | |
| path: pr/ | |
| if: github.event_name == 'pull_request' |