Skip to content

Add Diff Javadoc workflow #4426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/diff-javadoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Diff Javadoc

on:
pull_request:

jobs:
build:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Make Dir
run: mkdir ~/diff

- uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: temurin
cache: gradle

- name: Build
run: ./gradlew kotlindoc

- name: Move original docs
run: mv build ~/diff/original

- uses: actions/checkout@v3

- name: Build
run: ./gradlew kotlindoc

- name: Move modified docs
run: mv build ~/diff/modified

- name: Diff 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
uses: mshick/add-pr-comment@v2
with:
message-path: diff.md