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,65 @@ 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
+ if : steps.runic.outputs.exit_code == 1
57
+ uses : peter-evans/find-comment@v3
58
+ id : find-comment
59
+ with :
60
+ issue-number : ${{ github.event.pull_request.number }}
61
+ comment-author : ' github-actions[bot]'
62
+ body-includes : ' <!-- runic-format-summary -->'
63
+
64
+ - name : Comment formatting suggestions
65
+ if : steps.runic.outputs.exit_code == 1
66
+ uses : peter-evans/create-or-update-comment@v4
67
+ with :
68
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
69
+ issue-number : ${{ github.event.pull_request.number }}
70
+ body : |
71
+ <!-- runic-format-summary -->
72
+
73
+ Your PR requires formatting changes to meet the project's style guidelines.
74
+ Please consider running [Runic](https://github.com/fredrikekre/Runic.jl) (`git runic ${{ github.base_ref }}`) to apply these changes.
75
+
76
+ <details>
77
+ <summary>Click here to view the suggested changes.</summary>
78
+
79
+ ```diff
80
+ ${{ steps.runic.outputs.diff }}
81
+ ```
47
82
48
- - name : Suggest changes
49
- uses : googleapis/code-suggester@v2
50
- env :
51
- ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
83
+ </details>
84
+ edit-mode : replace
85
+
86
+ - name : Update stale comment
87
+ if : steps.runic.outputs.exit_code == 0 && steps.find-comment.outputs.comment-id
88
+ uses : peter-evans/create-or-update-comment@v4
52
89
with :
53
- command : review
54
- pull_number : ${{ github.event.pull_request.number }}
55
- git_dir : ' .'
90
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
91
+ issue-number : ${{ github.event.pull_request.number }}
92
+ body : |
93
+ <!-- runic-format-summary -->
94
+
95
+ Your PR no longer requires formatting changes. Thank you for your contribution!
96
+ edit-mode : replace
97
+
98
+ # XXX: if Github ever supports allow-failure (actions/runner#2347)
99
+ # - name: Propagate exit code
100
+ # run: |
101
+ # exit ${{ steps.runic.outputs.exit_code }}
0 commit comments