Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit 453f58e

Browse files
committed
ci: 👷 Add PR comment notification for build and API doc generation
- Replace `hasura/comment-progress@v2.3.0` with `peter-evans/create-or-update-comment@v4` - Add new job `write-comment` in GitHub Actions workflow - The job runs after `build`, `maven-plugin-build`, `generate-api-docs`, and `generate-grpc-api-docs` - It checks the status of these jobs and posts an appropriate message to the PR with a link to the workflow run - Improves visibility and provides quick feedback on the CI/CD process for each PR
1 parent 4ab90e9 commit 453f58e

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

.github/workflows/build-and-run-example-project.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ env:
1313

1414
jobs:
1515
build:
16-
if: ${{ github.repository == 'TongchengOpenSource/smart-doc' && github.event.pull_request.changed_files > 0 }} # Run this job only if there are file changes
1716
runs-on: ubuntu-latest
1817

1918
steps:
@@ -338,4 +337,41 @@ jobs:
338337
uses: actions/upload-artifact@v4
339338
with:
340339
name: error-log-${{ runner.os }}-grpc-api-doc
341-
path: logs
340+
path: logs
341+
342+
write-comment:
343+
if: ${{ always() }}
344+
name: write comment to pr
345+
needs: [build, maven-plugin-build, generate-api-docs, generate-grpc-api-doc]
346+
runs-on: ubuntu-latest
347+
timeout-minutes: 5
348+
steps:
349+
- name: Set status message
350+
id: set-status
351+
run: |
352+
job_status=""
353+
354+
# Set the job status message
355+
if [ ${{ needs.build.result }} == 'success' ] && [ ${{ needs.maven-plugin-build.result }} == 'success' ] && [ ${{ needs.generate-api-docs.result }} == 'success' ] && [ ${{ needs.generate-grpc-api-doc.result }} == 'success' ]; then
356+
job_status=":green_heart: All jobs completed successfully! :tada:"
357+
else
358+
job_status=":x: Some jobs failed. Please check the details."
359+
fi
360+
361+
echo "job_status=$job_status" >> $GITHUB_ENV
362+
363+
- name: Comment on the pull request
364+
uses: peter-evans/create-or-update-comment@v4
365+
with:
366+
token: ${{ secrets.GITHUB_TOKEN }}
367+
repository: ${{ github.repository }}
368+
issue-number: ${{ github.event.number }}
369+
body: |
370+
Pull requests [#${{ github.event.number }}](https://github.com/${{ github.repository }}/pull/${{ github.event.number }}) report:
371+
${{ env.job_status }}
372+
[DETAILS](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
373+
374+
- ${{ needs.build.result == 'success' && '✅' || '❌' }} - build: ${{ needs.build.result }}
375+
- ${{ needs.maven-plugin-build.result == 'success' && '✅' || '❌' }} - maven-plugin-build: ${{ needs.maven-plugin-build.result }}
376+
- ${{ needs.generate-api-docs.result == 'success' && '✅' || '❌' }} - generate-api-docs(rest, dubbo, javadoc, websocket): ${{ needs.generate-api-docs.result }}
377+
- ${{ needs.generate-grpc-api-doc.result == 'success' && '✅' || '❌' }} - generate-grpc-api-doc(ubuntu-latest, macos-latest, windows-latest): ${{ needs.generate-grpc-api-doc.result }}

.github/workflows/pr-comment.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ jobs:
1111
pull-requests: write
1212
name: Say thanks for the PR and hint to document
1313
steps:
14-
- name: comment on the pull request
15-
uses: hasura/comment-progress@v2.3.0
14+
- name: Comment on the pull request
15+
uses: peter-evans/create-or-update-comment@v4
1616
with:
17-
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
token: ${{ secrets.GITHUB_TOKEN }}
1818
repository: ${{ github.repository }}
19-
number: ${{ github.event.number }}
20-
id: thanks-and-hint-to-document
21-
recreate: true
22-
message: |
19+
issue-number: ${{ github.event.number }}
20+
body: |
2321
Thanks for your this PR. :pray:
2422
Please check again for your PR changes whether contains any usage configuration change such as `Add new configuration`, `Change default value of configuration`.
2523
If so, please add or update documents(markdown type) in `docs/` for repository [smart-doc-group/smart-doc-group.github.io](https://github.com/smart-doc-group/smart-doc-group.github.io/tree/master/docs)

0 commit comments

Comments
 (0)