Skip to content

Commit 66a3a0e

Browse files
committed
update
Signed-off-by: Andreas Fehlner <fehlner@arcor.de>
1 parent 04ffbf1 commit 66a3a0e

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

.github/workflows/pr_checks.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
runs-on: ubuntu-latest
2323
permissions:
2424
contents: read
25-
pull-requests: write
2625
steps:
2726
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2827
with:
@@ -40,6 +39,13 @@ jobs:
4039
set +e
4140
lintrunner f --all-files -v
4241
exit 0
43-
- uses: parkerbxyz/suggest-changes@bd099ea0d10f0e9efeb9e46d604bbe6d7a80bc34
42+
- name: Save PR number and diff
43+
run: |
44+
mkdir -p ./pr_artifacts
45+
echo "${{ github.event.pull_request.number }}" > ./pr_artifacts/pr_number
46+
git diff > ./pr_artifacts/lintrunner.diff
47+
- name: Upload artifacts
48+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
4449
with:
45-
comment: 'You can commit the suggested changes from lintrunner.'
50+
name: pr-artifacts
51+
path: pr_artifacts/
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) ONNX Project Contributors
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: PR Checks Comment
6+
7+
on:
8+
workflow_run:
9+
workflows: ["PR Checks"]
10+
types:
11+
- completed
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
suggest-changes:
18+
name: Suggest fixes
19+
runs-on: ubuntu-latest
20+
if: github.event.workflow_run.event == 'pull_request'
21+
permissions:
22+
contents: read
23+
pull-requests: write
24+
steps:
25+
- name: Download artifacts
26+
id: download
27+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
28+
continue-on-error: true
29+
with:
30+
name: pr-artifacts
31+
path: pr_artifacts/
32+
run-id: ${{ github.event.workflow_run.id }}
33+
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Get PR number
35+
if: steps.download.outcome == 'success'
36+
id: pr
37+
run: echo "number=$(cat pr_artifacts/pr_number)" >> "$GITHUB_OUTPUT"
38+
- name: Check if diff is empty
39+
if: steps.download.outcome == 'success'
40+
id: diff
41+
run: |
42+
if [ -s pr_artifacts/lintrunner.diff ]; then
43+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
46+
fi
47+
- name: Checkout PR
48+
if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true'
49+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
50+
with:
51+
ref: refs/pull/${{ steps.pr.outputs.number }}/head
52+
persist-credentials: false
53+
- name: Apply lintrunner fixes
54+
if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true'
55+
run: git apply pr_artifacts/lintrunner.diff
56+
- name: Suggest changes
57+
if: steps.download.outcome == 'success' && steps.diff.outputs.has_changes == 'true'
58+
uses: parkerbxyz/suggest-changes@bd099ea0d10f0e9efeb9e46d604bbe6d7a80bc34
59+
with:
60+
comment: 'You can commit the suggested changes from lintrunner.'

0 commit comments

Comments
 (0)