Master test #8048
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: Diff CCD definition | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| target: [branch, master] | |
| steps: | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: corretto | |
| java-version: 21 | |
| - name: Checkout ${{ matrix.target }} | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ matrix.target == 'master' && 'master' || github.head_ref }} | |
| path: build/${{ matrix.target }} | |
| - name: Build CCD Config (${{ matrix.target }}) | |
| run: ./gradlew generateCCDConfig | |
| working-directory: build/${{ matrix.target }} | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.target }} | |
| path: build/${{ matrix.target }}/build/definitions/PCS | |
| report: | |
| permissions: | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: branch | |
| path: build/branch | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: master | |
| path: build/master | |
| - name: Generate report | |
| id: ccd-diff | |
| run: | | |
| set -euo pipefail | |
| mkdir -p ccd-report | |
| npx -q @hmcts/ccd-diff build/master build/branch > ccd-report/ccd-diff-report.html | |
| SUMMARY_FILE="ccd-report/ccd-comment-summary.md" | |
| MAX_CHARS=65000 | |
| REPORT_FILE="ccd-report/ccd-diff-report.html" | |
| TOTAL_CHARS=$(wc -c < "$REPORT_FILE") | |
| head -c $MAX_CHARS "$REPORT_FILE" > "$SUMMARY_FILE" | |
| if [ "$TOTAL_CHARS" -gt "$MAX_CHARS" ]; then | |
| printf '\n\n…(truncated)…\n' >> "$SUMMARY_FILE" | |
| else | |
| printf '\n' >> "$SUMMARY_FILE" | |
| fi | |
| { | |
| echo "report-dir=ccd-report" | |
| echo "report-path=$REPORT_FILE" | |
| echo "summary-path=$SUMMARY_FILE" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Upload HTML report | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ccd-diff-report-${{ github.run_id }} | |
| path: ${{ steps.ccd-diff.outputs.report-path }} | |
| - name: Create or update CCD diff comment | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| SUMMARY_PATH: ${{ steps.ccd-diff.outputs.summary-path }} | |
| RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?check_suite_focus=true | |
| run: | | |
| BODY_FILE="$(mktemp)" | |
| { | |
| printf '# CCD diff summary\n\n' | |
| printf '👉 Full report: %s\n\n' "$RUN_URL" | |
| cat "$SUMMARY_PATH" | |
| } > "$BODY_FILE" | |
| COMMENT_ID=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" \ | |
| --json comments \ | |
| --jq '[.comments[] | |
| | select(.body | startswith("# CCD diff summary")) | |
| | .url | capture("#issuecomment-(?<id>[0-9]+)$").id][-1]') | |
| if [ -n "$COMMENT_ID" ]; then | |
| echo "📝 Updating existing CCD diff comment ($COMMENT_ID)" | |
| gh api repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID \ | |
| -X PATCH -f body="$(cat "$BODY_FILE")" | |
| else | |
| echo "💬 Creating new CCD diff comment" | |
| gh pr comment "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --body-file "$BODY_FILE" | |
| fi |