77
88permissions :
99 contents : read
10-
11- # needed for julia-actions/cache to delete old caches
1210 actions : write
13-
14- # needed for googleapis/code-suggester
1511 pull-requests : write
1612
1713jobs :
1814 runic :
1915 runs-on : ubuntu-latest
2016 if : github.event.pull_request.draft == false
2117 steps :
22- - uses : actions/checkout@v4
18+ - name : Check out repository
19+ uses : actions/checkout@v4
2320 with :
2421 ref : ${{github.event.pull_request.head.ref}}
2522 repository : ${{github.event.pull_request.head.repo.full_name}}
@@ -40,16 +37,64 @@ jobs:
4037 sudo mv git-runic /usr/local/bin
4138
4239 - name : Run Runic
40+ id : runic
4341 run : |
4442 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+ ```
4781
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
5288 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