-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thomas Farr <[email protected]>
- Loading branch information
Showing
3 changed files
with
163 additions
and
21 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
.github/pr-comment-templates/pr-change-analysis.template.md
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,23 @@ | ||
## Changes Analysis | ||
|
||
**Commit SHA:** {{.after_sha}} | ||
**Comparing To SHA:** {{.before_sha}} | ||
|
||
### API Changes | ||
|
||
#### Summary | ||
{{.api_changes_summary}} | ||
|
||
#### Report | ||
The full API changes report is available at: {{.api_changes_report_url}} | ||
|
||
### API Coverage | ||
{{with .api_coverage}} | ||
|
||
| | Before | After | Δ | | ||
|--------------:|-----------------------------------------------------|---------------------------------------------------|---------------------------------------------------| | ||
| Covered (%) | {{.before.covered}} ({{.before.covered_pct}} %) | {{.after.covered}} ({{.after.covered_pct}} %) | {{.covered_delta}} ({{.covered_pct_delta}} %) | | ||
| Uncovered (%) | {{.before.uncovered}} ({{.before.uncovered_pct}} %) | {{.after.uncovered}} ({{.after.uncovered_pct}} %) | {{.uncovered_delta}} ({{.uncovered_pct_delta}} %) | | ||
| Unknown | {{.before.specified_but_not_provided}} | {{.after.specified_but_not_provided}} | {{.specified_but_not_provided_delta}} | | ||
|
||
{{end}} |
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 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,74 @@ | ||
name: Comment with PR Analysis | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- Analyze PR Changes | ||
types: | ||
- completed | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: refs/heads/main | ||
sparse-checkout: | | ||
.github | ||
- name: Download PR Comment Payload | ||
uses: actions/download-artifact@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
name: pr-comment | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Parse Payload | ||
shell: bash -eo pipefail {0} | ||
run: | ||
PR_NUMBER=$(jq -r '.pr_number' ./pr-comment.json) | ||
COMMENT_IDENTIFIER=$(jq -r '.comment_identifier' ./pr-comment.json) | ||
TEMPLATE_NAME=$(jq -r '.template_name' ./pr-comment.json) | ||
TEMPLATE_DATA=$(jq -c '.template_data' ./pr-comment.json) | ||
|
||
vars=( | ||
PR_NUMBER | ||
COMMENT_IDENTIFIER | ||
TEMPLATE_NAME | ||
TEMPLATE_DATA | ||
) | ||
|
||
{ | ||
for var in "${vars[@]}" | ||
do | ||
echo "${var}=${!var}" | ||
done | ||
} | tee "$GITHUB_ENV" | ||
|
||
- name: Render Comment Template | ||
uses: chuhlomin/render-template | ||
id: render | ||
with: | ||
template: .github/pr-comment-templates/${{ env.TEMPLATE_NAME }}.template.md | ||
vars: ${{ env.TEMPLATE_DATA }} | ||
|
||
- name: Find Existing Comment | ||
uses: peter-evans/find-comment@v3 | ||
id: fc | ||
with: | ||
issue-number: ${{ env.PR_NUMBER }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: ${{ env.COMMENT_IDENTIFIER }} | ||
|
||
- name: Create or Update Comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ env.PR_NUMBER }} | ||
body: ${{ steps.render.outputs.result }} | ||
edit-mode: replace |