Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
108 lines (85 loc) · 3.31 KB

File metadata and controls

108 lines (85 loc) · 3.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: commit-suggest.yaml
on:
workflow_run:
workflows: ["rcc"]
types:
- completed
permissions:
contents: write
pull-requests: write
jobs:
commit-suggest:
runs-on: ubuntu-26.04
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Show event payload
run: |
echo '${{ toJson(github.event) }}' | jq .
shell: bash
- name: Checkout PR
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Download artifact
uses: actions/download-artifact@v6
with:
name: changes-patch
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
continue-on-error: true
- name: Check if artifact exists
id: check-artifact
run: |
if [ -f changes.patch ]; then
echo "has_diff=true" >> $GITHUB_OUTPUT
else
echo "has_diff=false" >> $GITHUB_OUTPUT
echo "No changes-patch artifact found"
fi
shell: bash
- name: Find PR number for branch from correct head repository
id: find-pr
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
PR_NUMBER=$(gh pr list --head ${{ github.event.workflow_run.head_branch }} --state open --json number,headRepositoryOwner --jq '.[] | select(.headRepositoryOwner.login == "${{ github.event.workflow_run.head_repository.owner.login }}") | .number' || echo "")
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
shell: bash
- name: Generate comment body
if: steps.check-artifact.outputs.has_diff == 'true'
id: comment-body
run: |
cat << 'EOF' > comment.md
## Formatting suggestions available
A patch file with formatting suggestions has been generated. You can apply it using one of these methods:
### Method 1: Apply via gh CLI
```bash
# Download and apply the patch directly
gh run download ${{ github.event.workflow_run.id }} --repo ${{ github.repository }} --name changes-patch && patch -p1 < changes.patch && rm changes.patch
```
Repo owners can also apply the patch automatically. Click the button to jump to the comment box, then post:
```
/apply-patch
```
[![Apply patch](https://img.shields.io/badge/Apply%20patch-%2Fapply--patch-2ea44f?style=for-the-badge&logo=github)](https://github.com/${{ github.repository }}/pull/${{ steps.find-pr.outputs.pr_number }}#new_comment_field)
### Method 2: View the patch
<details>
<summary>Click to see the patch contents</summary>
```diff
EOF
cat changes.patch >> comment.md
cat << 'EOF' >> comment.md
```
</details>
---
*This comment was automatically generated by the commit-suggester workflow.*
EOF
shell: bash
- name: Post or update comment
if: steps.check-artifact.outputs.has_diff == 'true'
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.find-pr.outputs.pr_number }}
file-path: comment.md
comment-tag: formatting-suggestions
mode: recreate
Morty Proxy This is a proxified and sanitized view of the page, visit original site.