-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #731 from Kotlin/kdocs-gh-action-2
KDocs GH actions
- Loading branch information
Showing
10 changed files
with
133 additions
and
55 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ max_line_length=120 | |
[*.json] | ||
indent_size=2 | ||
|
||
[*.yaml] | ||
[{*.yaml,*.yml}] | ||
indent_size=2 | ||
|
||
[*.ipynb] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Auto-commit generated code | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
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: Run Gradle task | ||
run: ./gradlew :core:processKDocsMain | ||
|
||
- name: Commit changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add ./core/generated-sources | ||
git diff --staged --quiet || git commit -m "Automated commit of generated code" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
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: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- 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 generated-sources/docs-update-${{ github.run_number }} | ||
echo "::set-output name=commit::$(git rev-parse HEAD)" | ||
- name: Remove old comments | ||
uses: actions/github-script@v5 | ||
if: steps.git-diff.outputs.changed == 'true' | ||
with: | ||
# language=js | ||
script: | | ||
const issue_number = context.issue.number; | ||
const {owner, repo} = context.repo; | ||
const comments = await github.rest.issues.listComments({ | ||
issue_number, | ||
owner, | ||
repo, | ||
}); | ||
const botComments = comments.data.filter( | ||
(comment) => comment.user.login === 'github-actions[bot]' | ||
); | ||
for (const comment of botComments) { | ||
await github.rest.issues.deleteComment({ | ||
comment_id: comment.id, | ||
owner, | ||
repo, | ||
}); | ||
} | ||
- name: Add comment to PR | ||
uses: actions/github-script@v5 | ||
if: steps.git-diff.outputs.changed == 'true' | ||
with: | ||
# language=js | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "Generated sources will be updated after merging this PR.\nPlease inspect the changes in [here](https://github.com/${{ github.repository }}/commit/${{ steps.git-commit.outputs.commit }}).", | ||
}); |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.