7
7
8
8
permissions :
9
9
contents : read
10
-
11
- # needed for julia-actions/cache to delete old caches
12
10
actions : write
13
-
14
- # needed for googleapis/code-suggester
15
11
pull-requests : write
16
12
17
13
jobs :
18
14
runic :
19
15
runs-on : ubuntu-latest
20
16
if : github.event.pull_request.draft == false
21
17
steps :
22
- - uses : actions/checkout@v4
18
+ - name : Check out repository
19
+ uses : actions/checkout@v4
23
20
with :
24
21
ref : ${{github.event.pull_request.head.ref}}
25
22
repository : ${{github.event.pull_request.head.repo.full_name}}
@@ -40,16 +37,64 @@ jobs:
40
37
sudo mv git-runic /usr/local/bin
41
38
42
39
- name : Run Runic
40
+ id : runic
43
41
run : |
44
42
set +e
45
- git runic origin/master
46
- [ $? -eq 2 ] && exit 1 || exit 0
43
+ MERGE_BASE=$(git merge-base origin/${{ github.base_ref }} HEAD) || exit 2
44
+ DIFF=$(git runic --diff $MERGE_BASE)
45
+ EXIT_CODE=$?
46
+
47
+ echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
48
+ echo "diff<<EOF" >> $GITHUB_OUTPUT
49
+ echo "$DIFF" >> $GITHUB_OUTPUT
50
+ echo "EOF" >> $GITHUB_OUTPUT
51
+
52
+ # if Runic failed, bail out
53
+ [ $EXIT_CODE -eq 2 ] && exit 1 || exit 0
54
+
55
+ - name : Find comment
56
+ uses : peter-evans/find-comment@v3
57
+ id : find-comment
58
+ with :
59
+ issue-number : ${{ github.event.pull_request.number }}
60
+ comment-author : ' github-actions[bot]'
61
+ body-includes : ' <!-- runic-format-summary -->'
62
+
63
+ - name : Comment formatting suggestions
64
+ if : steps.runic.outputs.exit_code == 1
65
+ uses : peter-evans/create-or-update-comment@v4
66
+ with :
67
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
68
+ issue-number : ${{ github.event.pull_request.number }}
69
+ body : |
70
+ <!-- runic-format-summary -->
71
+
72
+ Your PR requires formatting changes to meet the project's style guidelines.
73
+ Please consider running [Runic](https://github.com/fredrikekre/Runic.jl) (`git runic ${{ github.base_ref }}`) to apply these changes.
74
+
75
+ <details>
76
+ <summary>Click here to view the suggested changes.</summary>
77
+
78
+ ```diff
79
+ ${{ steps.runic.outputs.diff }}
80
+ ```
47
81
48
- - name : Suggest changes
49
- uses : googleapis/code-suggester@v2
50
- env :
51
- ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82
+ </details>
83
+ edit-mode : replace
84
+
85
+ - name : Update stale comment
86
+ if : steps.runic.outputs.exit_code == 0 && steps.find-comment.outputs.comment-id
87
+ uses : peter-evans/create-or-update-comment@v4
52
88
with :
53
- command : review
54
- pull_number : ${{ github.event.pull_request.number }}
55
- git_dir : ' .'
89
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
90
+ issue-number : ${{ github.event.pull_request.number }}
91
+ body : |
92
+ <!-- runic-format-summary -->
93
+
94
+ Your PR no longer requires formatting changes. Thank you for your contribution!
95
+ edit-mode : replace
96
+
97
+ # XXX: if Github ever supports allow-failure (actions/runner#2347)
98
+ # - name: Propagate exit code
99
+ # run: |
100
+ # exit ${{ steps.runic.outputs.exit_code }}
0 commit comments