Pipelines #4627
This file contains 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 Javadoc | |
on: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Make diff directory | |
run: mkdir ~/diff | |
- name: Checkout PR branch | |
uses: actions/checkout@v4.1.1 | |
with: | |
fetch-depth: 2 | |
submodules: true | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4.1.0 | |
with: | |
java-version: 17 | |
distribution: temurin | |
cache: gradle | |
- name: Generate docs for PR branch | |
run: ./gradlew kotlindoc | |
- name: Move branch docs to diff directory | |
run: mv build ~/diff/modified | |
- name: Checkout main | |
uses: actions/checkout@v4.1.1 | |
with: | |
ref: ${{ github.base_ref }} | |
- name: Generate docs for main | |
run: ./gradlew kotlindoc | |
- name: Move main docs to diff directory | |
run: mv build ~/diff/original | |
- name: Get diff between main and Branch docs | |
run: > | |
`# Recursively diff directories, including new files, git style, with 3 lines of context` | |
diff -wEburN ~/diff/original ~/diff/modified | |
`# Remove the first line and new file signifier of the output` | |
| tail -n +2 | |
`# Replace the diff new file signifier with the end and start of a new codeblock` | |
| sed "s/^diff.*$/\`\`\`\\n\`\`\`diff/g" | |
`# Add a collapsable block, summary, and start the first code block on the first line` | |
| sed "1s/^/<details>\\n<summary>Javadoc Changes:<\/summary>\\n\\n\`\`\`diff\\n/" | |
`# Close the final code block and close the collapsable on the final line` | |
| sed "$ s/$/\\n\`\`\`\\n<\/details>/" | |
`# Write to diff.md for later` | |
> diff.md | |
- name: Add comment | |
continue-on-error: true | |
uses: mshick/add-pr-comment@a65df5f64fc741e91c59b8359a4bc56e57aaf5b1 | |
with: | |
message-path: diff.md |