Add GitHub Actions workflow to build bootJar on comment#3605
Add GitHub Actions workflow to build bootJar on comment#3605
Conversation
This workflow builds a boot JAR when a comment is made on a PR. It checks out the repository, sets up JDK, builds the JAR, lists the built JARs, uploads the artifact, and comments on the PR with the JAR link.
|
/buildJar |
|
Caution Review failedThe pull request is closed. WalkthroughA new GitHub Actions workflow is introduced that automatically builds a bootJar artifact when a PR comment containing "/buildJar" is posted. The workflow checks out the code, sets up JDK 17, builds the JAR, uploads it as an artifact, and posts a comment with the artifact link. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant GitHub as GitHub Actions
participant Build as Build Job
participant Artifact as Artifact Store
participant PR as PR Comment
User->>GitHub: Comment "/buildJar" on PR
activate GitHub
GitHub->>Build: Trigger workflow
activate Build
Build->>Build: Checkout repo
Build->>Build: Setup JDK 17
Build->>Build: Build bootJar
alt JAR(s) found
Build->>Build: Generate file list
Build->>Artifact: Upload artifact
Build->>PR: Post success comment<br/>with artifact link
else No JARs found
Build->>PR: Post failure comment
end
deactivate Build
deactivate GitHub
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new GitHub Actions workflow that allows building bootJar artifacts on-demand when a PR comment containing /buildJar is posted. This provides a convenient way to generate test builds from pull requests without merging or manual local builds.
Key Changes:
- Adds
build-bootJar-on-comment.yamlworkflow triggered by issue comments - Implements
/buildJarcommand to build and upload JAR artifacts - Automatically comments on PRs with links to the generated artifacts
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 17 (Corretto) with Gradle cache | ||
| uses: actions/setup-java@v4 |
There was a problem hiding this comment.
The workflow uses actions/setup-java@v4 while other workflows in the repository use actions/setup-java@v5 (see qa.yml, gradle.yml, pre-qa.yml, benchmark.yml). Please update to v5 for consistency.
| uses: actions/setup-java@v4 | |
| uses: actions/setup-java@v5 |
|
|
||
| - name: Upload JAR artifact | ||
| id: upload_jar | ||
| uses: actions/upload-artifact@v4 |
There was a problem hiding this comment.
The workflow uses actions/upload-artifact@v4 while other workflows in the repository use actions/upload-artifact@v5 (see gradle.yml line 52, benchmark.yml line 73, pre-qa.yml line 39). Please update to v5 for consistency.
| uses: actions/upload-artifact@v4 | |
| uses: actions/upload-artifact@v5 |
| body: | | ||
| ✅ Собраны JAR-файлы для этого PR по команде `/buildJar`. | ||
|
|
||
| **Артефакт:** [${{ steps.upload_jar.outputs.artifact-name }}](${{ steps.upload_jar.outputs.artifact-url }}) |
There was a problem hiding this comment.
The output artifact-name doesn't exist in actions/upload-artifact@v4 (or v5). The available outputs are:
artifact-id: The ID of the artifactartifact-url: The URL to download the artifact
To display the artifact name, you should use the input value directly: bootJar-${{ github.run_id }} instead of ${{ steps.upload_jar.outputs.artifact-name }}.
| **Артефакт:** [${{ steps.upload_jar.outputs.artifact-name }}](${{ steps.upload_jar.outputs.artifact-url }}) | |
| **Артефакт:** [bootJar-${{ github.run_id }}](${{ steps.upload_jar.outputs.artifact-url }}) |
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write # писать комментарии в PR (issues API) |
There was a problem hiding this comment.
[nitpick] The permissions may be insufficient. While issues: write allows commenting on issues, for PR comments you should also consider adding pull-requests: write permission to ensure proper access to all PR-related operations. Although the issues API works for PR comments, it's more explicit and future-proof to include both permissions.
| issues: write # писать комментарии в PR (issues API) | |
| issues: write # писать комментарии в PR (issues API) | |
| pull-requests: write # явное разрешение для операций с PR |
| id: list_jars | ||
| run: | | ||
| if ! ls build/libs/*.jar >/dev/null 2>&1; then | ||
| echo "No JAR found in build/libs" |
There was a problem hiding this comment.
[nitpick] Minor spelling: In English error messages, the standard format would be "No JAR files found" rather than "No JAR found" for clarity, especially since the workflow might build multiple JAR files.
| echo "No JAR found in build/libs" | |
| echo "No JAR files found in build/libs" |
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
The workflow uses actions/checkout@v4 while other workflows in the repository use actions/checkout@v5 (see qa.yml, gradle.yml, pre-qa.yml, benchmark.yml, rebase.yml). Please update to v5 for consistency.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@v5 |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
Critical bug: The workflow checks out the default branch instead of the PR branch. When triggered by an issue_comment event, the checkout action doesn't automatically know which PR branch to use. You need to:
- Fetch the PR data using the GitHub API (similar to how
qa.ymldoes it) - Use the
refparameter in checkout to specify the PR branch
Example approach from rebase.yml:
- uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0Or fetch PR data first and checkout the head ref (see qa.yml lines 27-40 for a complete pattern).
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| steps: | |
| - name: Get PR branch | |
| id: pr | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number | |
| }); | |
| core.setOutput('head_ref', pr.data.head.ref); | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.pr.outputs.head_ref }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 |
|
Add GitHub Actions workflow to build bootJar on comment



This workflow builds a boot JAR when a comment is made on a PR. It checks out the repository, sets up JDK, builds the JAR, lists the built JARs, uploads the artifact, and comments on the PR with the JAR link.
Описание
Связанные задачи
Closes
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно
Summary by CodeRabbit