Skip to content

TEST KDoc gh action

TEST KDoc gh action #9

name: Show generated code in PR
on:
pull_request:
types:
- edited
- opened
- synchronize
- converted_to_draft
- ready_for_review
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Configure Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Run Gradle task
run: ./gradlew :core:processKDocsMain
- name: Check for changes in generated sources
id: git-diff
run: echo "::set-output name=changed::$(if git diff --quiet './core/generated-sources'; then echo 'false'; else echo 'true'; fi)"
- name: Commit and push if changes
id: git-commit
if: steps.git-diff.outputs.changed == 'true'
run: |
git checkout -b generated-sources/docs-update-${{ github.run_number }}
git add './core/generated-sources'
git commit -m "Update generated sources with recent changes"
git push origin docs-update-${{ github.run_number }}
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Add comment to PR
uses: actions/github-script@v5
if: steps.git-diff.outputs.changed == 'true'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Generated sources have been updated. Please check the changes at this commit: [link](https://github.com/${{ github.repository }}/commit/${{ steps.git-commit.outputs.commit }})",
})